- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 09:31 AM
Hi all,
The requirement is to populate Install base item from my sold product on the case table. I have tried the below logic but somewhere it's going wrong and not working.
Business Rule:
When: after
Insert: true
Order: 200
Script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var installBase = new GlideRecord('sn_install_base_item');
installBase.addQuery('name', current.sold_product.name);
installBase.query();
if (installBase.next()) {
current.u_installed_base_item = installBase.sys_id;
//current.update();
}
})(current, previous);
I tried with current.update() and it was working, but it's not the best practice. Kindly guide me. A working code also would make a difference to me.
Best Regards,
Sreesh Surendran
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2024 07:33 AM
Hi @sreeshsurendran,
Try using Before BR instead of After BR. Hope that works.
Mark the response correct and helpful if the answer assisted your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2024 07:33 AM
Hi @sreeshsurendran,
Try using Before BR instead of After BR. Hope that works.
Mark the response correct and helpful if the answer assisted your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 09:41 PM
Thanks @Rupanjani - it worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 01:14 PM
Does anyone have a script for the reverse use case of populating the sold product based on the install base item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
This is what i have client side onChange script:
var ga = new GlideAjax('ScriptIncludename');
ga.addParam('sysparm_name', 'functionName');
ga.addParam('sysparm_install_base', newValue); // install_base sys_id
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('sold_product', response);
} else {
g_form.clearValue('sold_product');
}
});
Function in script include :
getSoldProduct: function() {
var installBaseId = this.getParameter('sysparm_install_base');
if (!installBaseId) return '';
var gr = new GlideRecord('sn_install_base_m2m_installed_product');
gr.addQuery('install_base_item', installBaseId);
gr.setLimit(1);
gr.query();
if (gr.next()) {
return gr.getValue('sold_product');
}
return '';
},
Important to note that the Client script and script include should be in same scope for this to work