Based on the selected values from the dorpdown fields in should hide the field in another table.

Eswari K
Tera Contributor

Hi Everyone,

In a table, there is a field that contains 3 dropdown values. When I select one of these values, it should show a UI action button at the top. Clicking this button should redirect to a custom table form. My task is that when I select the first value in the dropdown, it should hide some fields in the custom table when I click the UI action. I prefer not to use UI policy because it won't reflect in the workspace.

 

For example:

when i click the "three" value from the dropdown. It will show the UI action.

EswariK_0-1714375930135.png

This UI action will redirect to the form page.

EswariK_1-1714376005913.png

Here, my task is to hide the short description field.

If i select the different dropdown values apart from "three" it shouldn't hide the fields.

3 REPLIES 3

Sujatha V M
Kilo Patron
Kilo Patron

@Eswari K  After redirecting to the new form, why don't you create a "Client Script" onLoad on the custom table to hide the short description field. 

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.

Hi @Sujatha V M, Thanks for your response.

I wrote the CS, but its not working fine. 

function onChange(){
function onChangeIncidentDropdown() {
    var dropdownValue = g_form.getValue('u_dropdown');

    var problemGr = new GlideRecord('u_id');

    // Hide fields in the Problem table based on the selected value in the Incident table
    if (dropdownValue == '3') {
       problemGr.setDisplay('description', false);
       
    }
}

// Attach the onChangeIncidentDropdown function to the onChange event of the dropdown field in the Incident table
g_form.addOnChange('u_dropdown', onChangeIncidentDropdown);
 

@Eswari K Your requirement states that UI action is routing to the custom table form. 

 

Your client script needs to be on that custom table and it will run only on that custom table.

 

Note: Do not use "GlideRecord" in client scripts as it's not a best practice, instead use GlideAjax and do the server side verifications in script includes. 

 

Please mark this as helpful and accept it as a solution if this resolves your query.

Thanks,

Sujatha V.M.

 

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.