Nour Khaled
01/21/2025, 11:56 AMCeligo AI
01/21/2025, 11:56 AMAI generated answer (using internal Slack threads):The issue you're facing is due to the fact that the
getCurrentSublistSubrecord method does not create a new subrecord if one does not exist. It only retrieves an existing subrecord. If the subrecord does not exist, it will return null.
In your code, you're trying to get the inventorydetail subrecord from the item sublist. If the inventorydetail subrecord does not exist for the current line, the method will return null.
To solve this issue, you need to first check if the subrecord exists using the hasCurrentSublistSubrecord method. If it does not exist, you can create a new subrecord using the setCurrentSublistSubrecord method.
Here is an example of how you can modify your code:
javascript
if (!currLine.hasCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail'
})) {
var invSubRec = currLine.setCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail',
subrecord: newSubrecord // replace newSubrecord with the actual subrecord you want to create
});
} else {
var invSubRec = currLine.getCurrentSublistSubrecord({
sublistId: 'item',
fieldId: 'inventorydetail'
});
}
******
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/21/2025, 11:57 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.879057467
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.878351
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.875727236
Celigo AI
01/21/2025, 11:57 AM