Script check to get value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 07:33 AM
Hello Experts,
We have "product inventory" table having "account field " and under that "Product characteristics" related lists available.
Requirement.
Account having "TSP" field and one "TSP" field on the interaction.
1.After creating a interaction Product.account.Tsp value need to update in the Interaction
Based on below script query mets. but below script is not working as expected
please correct me.
BR :After : Insert/update .
Table: Interaction.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 09:21 AM
@akin9 Please see if this works.
(function executeRule(current, previous) {
var account = current.account.toString();
var inventory = new GlideRecord('sn_prd_invt_product_inventory');
inventory.addQuery('account', account);
inventory.query();
while (inventory.next()) {
var characteristic = new GlideRecord('sn_prd_pm_product_characteristics');
characteristic.addQuery('inventory', inventory.sys_id);
characteristic.addEncodedQuery('characteristic.nameSTARTSWITHadditionalInfo^characteristic_valueLIKE"telecomServicePriority"');
characteristic.query();
if (characteristic.next()) {
current.u_tsp = inventory.account.u_tsp_level.toString();
current.update();
break;
}
}
})(current, previous);
If the above script doesn't work then check if the following query is returning any result or not.
var characteristic = new GlideRecord('sn_prd_pm_product_characteristics');
characteristic.addQuery('inventory', inventory.sys_id);
characteristic.addEncodedQuery('characteristic.nameSTARTSWITHadditionalInfo^characteristic_valueLIKE"telecomServicePriority"')
characteristic.query();
if (characteristic.next()) {
current.u_tsp = inventory.account.u_tsp_level;
current.update();
break;
}
Try to run this as a background script and see if it returns any result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2024 10:24 PM
Thank you for your sharing it was helpful to achieve my scenarios.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-16-2024 12:21 AM
@akin9 Could you please mark the response an accepted solution if it managed to address your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2024 11:13 AM
@akin9 , second to @Sandeep Rajput
System allow to accept more that one reply as accepted solutions.