Next Experience UI Base on Check box selection show/hide text area using script

SundaramR
Tera Guru

Hi,

 

I have page with check box and text area named textarea_1,  based on the check box selection show/hide text area using checkbox event.  using below script in the event, but its not hiding the textarea when I uncheck the  checkbox. How to fix this script?

 

/**
 * @Param {params} params
 * @Param {api} params.api
 * @Param {any} params.event
 */
function evaluateEvent({
    api,
    event
}) {
    console.log(event.payload.value);
    api.setState("textAreaShow", event.payload.value);

    if (api.update) {
        api.update();
    }
    return {
        propName: "textarea_1",
        value: event.payload.value
    };
}

 I also tried with textAreaShow client state parameter still its not working.

 

Thanks

 

4 REPLIES 4

Martin Friedel
Mega Sage

Hello,

 

I believe you can achieve similar with a simple Client Script.

 

  1. Create new Client Script
    • Table: <Record's table>
    • UI Type: All
    • Type: onChange
    • Field Name: <Checkbox name>
    • Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	
    if (newValue === 'true') {
        g_form.setVisible('textarea_1', true);
    } else {
        g_form.setVisible('textarea_1', false);
    }
	
}

If you want to run this Client Script only in Workspace, uncheck Global checkbox and write form view names into the field.

 

If my answer helped you, please mark it as correct and helpful, thank you 👍
Martin

This is Core UI script, I am looking script for Next Experience UI form.

I understand. I tested this script in Service Operations Workspace and it works.

@Martin Friedel 

 

My Check box is UI component, its not table filed. So I can't add the client script like above.

 

 

checkbox.png