script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 01:06 AM
Hi Team ,
We have requirement on catalog .
Catalog - MSF
If Type of request ' MSF table change ' selected
Below variables has to be populated '
5. Company Code (tick box multi-selection)
6. Function (drop down)
7. Action (drop down)
8. Code Type (free text)
9. Code (free text)
10. Description (free text) [ NOT REQ]
11. Report Description (free text)
12. Execution Date & Time (calendar selection)
13. Business Justification (free text)
Custom conditions
a) If function is FMGRM, and action is add, then the "code type" and "report description" fields are not there, and an extra free text field called "Value Change" is under the Description field.
b) If function is FMMENU, and action is add, then the "code type" and "report description" fields are not there
Values for variable function and action
We have a field ' FUNCTION' with below values
FMCODE
FMCP
FMGRM
FMMENU
Other
Field -
Action:
Add
Update
Delete
If I write UI policy there is conflicting happening .
So can anyone Instead of UI Policy , please provide me the client script
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 03:39 AM - edited 04-12-2024 06:31 AM
Hi @nameisnani,
Hope you are doing well.
Request you to please provide some snapshots of the Catalog, its Variables, and Ui Policy so that I can help you in solving the query as soon as possible.
Thanks
Aakash Garg
ServiceNow Developer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 04:03 AM
Hi @nameisnani
Without information from the form or backend catalog variables, it's a bit challenging to build the logic. Could you please share some screenshots to fulfill the requirements?
However, I can provide a demo client script for you.
SS - 1
Applies to : A catalog Item
Catalog ITEM : MSF
Variable Name : Type of Request
Code : Similarly you can add your logic for On form load in this same Catalog Client script ..
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var functionField = g_form.getValue('function');
var actionField = g_form.getValue('action');
if ((functionField === 'FMGRM' && actionField === 'Add') || (functionField === 'FMMENU' && actionField === 'Add')) { //let's assume backend value is 'Add' .. u can use your value
//if not manadatory fields do like this
g_form.setDisplay('code_type', false);
g_form.setDisplay('report_description', false);
//if manadatory fields do like this
g_form.setMandatory('code_type', false);
g_form.setDisplay('code_type', false);
g_form.setMandatory('report_description', false);
g_form.setDisplay('report_description', false);
g_form.setDisplay('u_value_change', true);
} else {
//if not manadatory fields do like this
g_form.setDisplay('code_type', false);
g_form.setDisplay('report_description', false);
g_form.setDisplay('u_value_change', false);
//if manadatory fields do like this
g_form.setMandatory('code_type', false);
g_form.setDisplay('code_type', false);
g_form.setMandatory('report_description', false);
g_form.setDisplay('report_description', false);
g_form.setMandatory('u_value_change', false);
g_form.setDisplay('u_value_change', true);
}
}
If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.
Thanks,
Subhashis Ratna