The CreatorCon Call for Content is officially open! Get started here.

Client script to make field mandatory and validate value

Wasd123
Tera Expert

Trying the set up a client side script to check the time_worked field on the change table. When the change status is being changed to closed complete (3) then it should make the time_worked field mandatory and should not allow the agent to save the state change if the time is less than 15 min. How could I achive this?

 

I have tried this to make it mandatory with onchange or onsubmit 

function onChange() {

if(g_form.getValue('state') == '3')
{
g_form.setMandatory('time_worked', true);
return false;
}
}

 

but even this part is not working, could somebody advice me?

3 REPLIES 3

Upender Kumar
Mega Sage

use above code on onSubmit client script

Jyoti Jadhav9
Tera Guru

Hi @Wasd123 ,

 

You can achieve this functionality using UI Policy and before update BR.

1. Create UI Policy to make the Time Worked field Mandatory when the state is closed.

Jyoti4_0-1676718784687.png

 

2. Create the Before Update BR and configure the condition as shown in the below screenshot:

State changes to closed && Time worked is less than 15 mins.

 

Jyoti4_0-1676718027540.png

3. Go to Action tab and select the "Abort Action" checkbox also can configure the message as per requirement. Please see the below screenshot.

Jyoti4_1-1676718359458.png

 

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

 

Thanks & Regards

Jyoti Jadhav

Jyoti Jadhav9
Tera Guru

Hi @Wasd123 ,

 

Were you able to achieve this functionality using the below logic?

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

 

Thanks & Regards

Jyoti Jadhav