- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2024 07:30 AM
Would someone please help me with scripting for an OnChange Client Script?
It needs to query the database to retrieve Order Management 'Order Line Items' that are associated with a 'Product Order'. The value it needs to return to the Client Script is a true/false field 'u_order_line_updated'
Order Line Item table: sn_ind_tmt_orm_order_line_item
Product Order table: sn_ind_tmt_orm_product_order
Matching field is the 'Order' field on the 'Product Order' table: order_line_item.order
Use Case:
When state changes to "X" on the Product Order table, check all associated Order Line Items, if any of them have the field 'u_order_line_updated' set to true, popup a confirmation window.
I have the Client Script created and GlideModel for the pop up working. I need help scripting this logic:
Query the Order Line Item table
If Order # matches the Order # in the Product table
Check if the Order Line Item field 'u_order_line_updated' is true
Do this for all associated Order Line Items
should return true or false
(check all associated Order Line Items, if any of them have the field 'u_order_line_updated' set to true)
Help is GREATLY appreciated!!!
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2024 02:24 PM
Hello @ssellmeyer
Here is the script include (server-side script) which checks if any order line item has u_order_line_updated field is true. If found, it returns true.
var GlideAjaxCalls = Class.create(); //GlideAjaxCalls is the script include name
GlideAjaxCalls.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getOrderLineUpdated: function() //getOrderLineUpdated is the function
{
var grI = new GlideRecord("sn_ind_tmt_orm_order_line_item"); //order line item table name
grI.addQuery("order", this.getParameter("sysparm_order")); //pleae use the sysparm_order when sending the value to the server side
grI.query();
while (grI.next()) {
if (grI.getValue("u_order_line_updated") == "1") //if it is true
return true;
}
return false;
},
type: 'GlideAjaxCalls'
});
Please post here if you have any difficulty. Happy to help 🙂
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 08:22 AM
Thank you very much. This is very helpful!
Unfortunately this is not working still.
So the goal is:
to query the Order Line Items that are associated with a Product Order (order # matches)
If any of the Order Line Items have been updated (custom true/false field named 'u_order_line_updated' on the 'Order Line Item' table
A Pop up a window comes up (via the OnChange Client Script)
What is happening right now is the pop up window comes up both when the OLIs are true or false
And my code "g_form.addInfoMessage('Order Line Item is True!');" does not display a message at all
See screenshots
The Script Include is in Global. The Client Script is in the 'Order Management' scope
Maybe I have incorrect values? Or maybe the IF statement in the Client Script function should be moved into the 'OnChange' function?
I really appreciate your help!
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 01:45 PM
Hi @ssellmeyer
Can you reach out to me here, so that I can help you easily
murthychintalapudi9@gmail.com
Murthy