>>To update the state, country, and address fields of a tax registration sublist in vendor record, create a search to retrieve the address of the vendor from the vendor record and extract the state, country, and primary address information.
>>This data can then be set into the corresponding fields of the tax registration sublist. Additionally, to update the tax registration number, you can retrieve the GST number from the vendor record and set it into the tax registration number field of the tax registration record.
var vendorSearchObj = search.create({
type: "vendor",
filters:
[
["address","isnotempty",""],
"AND",
["custentity_gst_number","isnotempty",""],
"AND",
["isinactive","is","F"],
"AND",
["address.isdefaultbilling","is","T"]
],
columns:
[
search.createColumn({name: "address", label: "Address"}),
search.createColumn({
name: "statedisplayname",
join: "Address",
label: "State/Province Display Name"
}),
search.createColumn({name: "custentity_gst_number", label: "GST No."}),
search.createColumn({name: "country", label: "Country"}),
search.createColumn({name: "internalid", label: "Internal ID"})
]
});
//create a search to retrieve state id
var stateSearchObj = search.create({
type: "state",
filters:
[
["fullname","is",state]
],
columns:
[
search.createColumn({
name: "id",
sort: search.Sort.ASC,
label: "Id"
}),
search.createColumn({name: "fullname", label: "Full Name"}),
search.createColumn({name: "shortname", label: "Short Name"}),
search.createColumn({name: "country", label: "Country"})
]
});
//set the fields
var lineNum = vendorRecord.selectLine({
sublistId: 'taxregistration',
line:0
});
var countryValue = vendorRecord.setCurrentSublistValue({
sublistId: 'taxregistration',
fieldId: 'nexuscountry',
value: country,
line:0
});
var stateValue = vendorRecord.setCurrentSublistValue({
sublistId: 'taxregistration',
fieldId: 'nexusstate',
value:stateId,
line: 0
});
var addValue = vendorRecord.setCurrentSublistValue({
sublistId: 'taxregistration',
fieldId: 'address',
value:addrss,
line: 0
});
vendorRecord.setCurrentSublistValue({
sublistId: 'taxregistration',
fieldId: 'taxregistrationnumber',
value:taxRegNum,
line: 0
});