- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 09:11 AM
Hi, here is my script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// get info from form
var oldState = oldValue;
var newState = newValue;
var currentIncident = g_form.getValue('number');
var childrenCount = g_form.getReference('child_incidents'); // error undefined :(
// alert(count);
if (newState == 6 && childrenCount > 0) {
// https://davidmac.pro/posts/2022-02-08-glidemodal/
var gm = new GlideModal("glide_prompt", true, 500);
gm.setTitle(currentIncident + " is a parent incident!");
gm.setPreference("title", "Enter yes if you would like to set " + currentIncident + " as resolved.\n ");
gm.setPreference("onPromptComplete", function(value) {
// if user NOT enter yes
if (value.toUpperCase() == "YES") {
// show alert
// g_form.clearMessages();
g_form.showFieldMsg("state", currentIncident + " set as resolved!", "info", false);
} else {
//show alert
g_form.setValue('state', oldState); // set state as previous state
g_form.showErrorBox("state", currentIncident + " not set as resolved!", false);
}
});
//window cancelled
gm.setPreference("onPromptCancel", function(value) {
g_form.showErrorBox('state', currentIncident + " not set as resolved!", false);
});
gm.render();
}
}
My form does not have child_incident directly on the form. I do not want it on my form.
My form is a default form.
I would love not to use GlideRecord.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 10:07 AM
Hello parrykgryze,
As per your script g_form.getReference("child_incidents"); wont work use instead g_form.getValue("child_incidents"); as the field type is an integer.
About the field not getting on the form it will not fetch value to you from the client script.
Workaround - Get the field on form in default view then create a UI Policy on the inc table and hide the child_incident field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 10:07 AM
Hello parrykgryze,
As per your script g_form.getReference("child_incidents"); wont work use instead g_form.getValue("child_incidents"); as the field type is an integer.
About the field not getting on the form it will not fetch value to you from the client script.
Workaround - Get the field on form in default view then create a UI Policy on the inc table and hide the child_incident field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 10:20 AM
I would suggest you build display business rule and then load the value of child incidents by business rule script in g_scratchpad variable, then user g_scratchpad.child_incidents in your client script.
Display business rules gets value from record level and can be accessed in client script