Need help on client script

nameisnani
Mega Sage

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  

17 REPLIES 17

nameisnani
Mega Sage

hi @Amit Verma @Deepak Shaerma 

 

any help here 

@nameisnani 

 

console.log will not work in client script. Please replace it with an alert or with g_form.addInfoMessage() and see the inputs you are getting.


Please mark this response as correct and helpful if it assisted you with your question.

nameisnani
Mega Sage

HI @Amit Verma 

 

i have checked with infomessage also , not working

Amit Verma
Kilo Patron
Kilo Patron

@nameisnani 

 

Are you getting the variable values in the info message ? If yes, try adding some more info messages in the script to see the point of failure. 


Please mark this response as correct and helpful if it assisted you with your question.

Deepak Shaerma
Kilo Sage
Kilo Sage

Hi @nameisnani 
Your final solution is , first go to maintain item and search for your catalog item and at the bottom of page check the correct variables value and noted down for your client script and then inside catalog client scripts create 2 onchange catalog client scripts. one for function field and other for Action field.
1. Client script Onchange Field = Function
2. Client Script Onchange Field = Action

DeepakShaerma_0-1712731346305.pngDeepakShaerma_1-1712731426246.pngDeepakShaerma_2-1712731452037.pngDeepakShaerma_3-1712731489078.png



var v1 = g_form.getValue('function'); //use backend value of function variable
    var v2 = g_form.getValue('action'); // use backend value of action variable
// use value for FMCODE and ADD of choices
    if(v1 == 'fmcode' && v2 == 'add') {
        // Hide two fields and unhide one
        g_form.setVisible('report_description', false);
        g_form.setVisible('description', false);
        g_form.setVisible('value_change', true);
    }
  else  if(v1 == 'fmcode' && v2 == 'add') {
        // Hide two fields and unhide one
        g_form.setVisible('report_description', false);
        g_form.setVisible('description', false);
        g_form.setVisible('value_change', false);
    } 
    else {
          g_form.setVisible('report_description', true);
        g_form.setVisible('description', true);
        g_form.setVisible('value_change', false);
    }