Make A Record Inactive From UI Action Workspace Client Script

Kapil_1409
Tera Contributor

I have a client UI action, which is available for workspace as well (This Ui action changes the Policy state to Draft which is currently in review). The requirement is to make comments mandatory as soon as we click on button 'back to draft'. here the code I have written in the workspace client script.

 

 

function onClick(g_form) {
    g_form.setValue('active', false);
    g_form.setValue('state', 'draft');
    g_form.setMandatory('comments', true);
    g_form.save();
}

 

But here everything is working as expected expect this is not setting the record to inactive. Anyone has any clue on this and how can I achieve this.

P.S. OOB this UI action is having server side script written, which is setting the state to draft and current.active to false. Since I have to come to my requirement to I deactivated to test create a new one

4 REPLIES 4

Anirudh Pathak
Mega Sage

Hi @Kapil_1409 ,

Since you are making the record inactive from client side, the "active" field should be present on the form. If not, just add the field on the form layout and your code should work.

 

Note : If you don't want active field to be visible on the form, add the "active" to form layout and hide it with the UI policy.

 

Hi Anirudh,

This doesn't work, I tried this, but it still doesn't make form inactive. although moving it to draft and making comments mandatory are working.

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Kapil_1409 Try this solution

SiddharamTakali_0-1713794702550.png

 

SiddharamTakali_2-1713794803015.png

 

Regards,

Siddharam

Hi Siddharam,

your solution is working fine also creates and issue. there is button post comments available. if user clicks that first and then click on UI action it dosent work although if he just write comments and not click Post comments button although simply click bac k to draft. It works, is there any solution for this.

Kapil_1409_0-1713859599667.png