Ron
01/15/2025, 4:14 PMCeligo AI
01/15/2025, 4:14 PMAI generated answer (using internal Slack threads):In SuiteScript, the
getCurrentSublistSubrecord
method is used to get the current subrecord from a sublist field. This method returns a Record
object representing the subrecord. However, it's important to note that this method loads the subrecord in view mode, which means it cannot be edited directly.
To edit a sublist subrecord, you would need to first select the line of the sublist that contains the subrecord using the selectLine
method. Then, you can use the hasCurrentSublistSubrecord
method to check if the sublist line has a subrecord. If it does, you can remove the subrecord using the removeCurrentSublistSubrecord
method, make your changes, and then commit the line using the commitLine
method.
Here is a code sample that demonstrates this process:
javascript
customer.selectLine({
sublistId: 'addressbook',
line: i
});
var hasSubrecord = customer.hasCurrentSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'addressbookaddress'
});
if (hasSubrecord) {
customer.removeCurrentSublistSubrecord({
sublistId: 'addressbook',
fieldId: 'addressbookaddress'
});
// Make your changes here
customer.commitLine({
sublistId: 'addressbook'
});
}
In the case of getting a subrecord of a specific item line, you can use the selectLine
method to select the line, and then use getCurrentSublistSubrecord
to get the subrecord.
javascript
context.currentRecord.selectLine({
sublistId: 'item',
line: i
});
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
01/15/2025, 4:15 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.870692432
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.87039566
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.863508701
Celigo AI
01/15/2025, 4:15 PM