Need help on client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 08:54 PM
HI Team ,
I want to fulfill the custom conditions through client script .
can anyone please provide me client script for my requirement .
we have catalog called ' XYZ '
We have a field ' FUNCTION' with below values
FMCODE
FMCP
FMGRM
FMMENU
Other
Field -
Action:
Add
Update
Delete
Total variables
1. Requested For
2. Line Manager
3. Short description
4. Request Type (drop down)
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)
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
I want to fulfill the custom conditions through client script .
NOTE - Here we can use UI Plocy , there some conflicts in the UI pocly , that why i want to achieve this via cilent script .
can any one please provide correct script for this .
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 09:12 PM
You can write onchange client script on function field, below is the sample script you can use:
var functionField = g_form.getValue('function');
var actionField = g_form.getValue('action');
// Reset fields to default state
g_form.setDisplay('code_type', true);
g_form.setMandatory('code_type', true);
g_form.setDisplay('report_description', true);
g_form.setMandatory('report_description', true);
g_form.setDisplay('value_change', false);
g_form.setMandatory('value_change', false);
// Check conditions based on function and action
if (functionField === 'FMGRM' && actionField === 'Add') {
g_form.setDisplay('code_type', false);
g_form.setMandatory('code_type', false);
g_form.setDisplay('report_description', false);
g_form.setMandatory('report_description', false);
g_form.setDisplay('value_change', true);
g_form.setMandatory('value_change', true);
}
else if (functionField === 'FMMENU' && actionField === 'Add') {
g_form.setDisplay('code_type', false);
g_form.setMandatory('code_type', false);
g_form.setDisplay('report_description', false);
g_form.setMandatory('report_description', false);
}
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 09:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 09:19 PM - edited 04-09-2024 09:22 PM
Hi @nameisnani
Please try with below On-Change client script. Note that you need to make it On-Change of function field and you also need to add a field called "Value Change" in your catalog item and make it visible as false On-Load so that we can make it visible once the user selects function value as "FMMENU".
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var functionValue = g_form.getValue('function');
var actionField = g_form.getValue('action');
// Checking the function value selected by the user is FMGRM
if (functionValue == 'fmgrm' && actionField === 'Add') //Assuming Value for Label FMGRM is frmgrm
{
g_form.setDisplay('code type', false);
g_form.setDisplay('report description', false);
g_form.setDisplay('value_change', true);
}
// If the function value is FMMENU
else if (functionValue == 'fmmenu' && actionField === 'Add'); //Assuming Value for Label FMMENU is fmmenu
{
g_form.setDisplay('code type', false);
g_form.setDisplay('report description', false);
}
}
Thanks and Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 09:41 PM
I have tried both scripts , still not working
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// //Type appropriate comment here, and begin script below
// var functionValue = g_form.getValue('function');
// var actionField = g_form.getValue('action');
// // Checking the function value selected by the user is FMGRM
// if (functionValue == 'fmgrm' && actionField === 'add') //Assuming Value for Label FMGRM is frmgrm
// {
// g_form.setDisplay('code_type', false);
// g_form.setDisplay('report_description', false);
// g_form.setDisplay('value_change', true);
// }
// // If the function value is FMMENU
// else if (functionValue == 'fmmenu' && actionField === 'add'); //Assuming Value for Label FMMENU is fmmenu
// {
// g_form.setDisplay('code_type', false);
// g_form.setDisplay('report_description', false);
// }
var functionField = g_form.getValue('function');
var actionField = g_form.getValue('action');
// Reset fields to default state
g_form.setDisplay('code_type', true);
g_form.setMandatory('code_type', true);
g_form.setDisplay('report_description', true);
g_form.setMandatory('report_description', true);
g_form.setDisplay('value_change', false);
g_form.setMandatory('value_change', false);
// Check conditions based on function and action
if (functionField === 'fmgrm' && actionField === 'add') {
g_form.setDisplay('code_type', false);
g_form.setMandatory('code_type', false);
g_form.setDisplay('report_description', false);
g_form.setMandatory('report_description', false);
g_form.setDisplay('value_change', true);
g_form.setMandatory('value_change', true);
} else if (functionField === 'fmmenu' && actionField === 'add') {
g_form.setDisplay('code_type', false);
g_form.setMandatory('code_type', false);
g_form.setDisplay('report_description', false);
g_form.setMandatory('report_description', false);
}
}
RESULT
NOTE - code type and report description we are making mandatory from UI policy
UI Ploicy screenshots
what shoud i do here please help me