Client script to set a field to read only if 30 days have passed

FredrikT
Tera Guru

Hello,

 

I am not sure where to go now with what I believe should be an onCellEdit client script on the pm_project table to set a custom field "u_original_end_date" to read only 30 days after the value of the "opend_at" field.   If the custom field is empty at that time , then it can be populated with another field "work_end" before being set to read only.

 

Here is what I have pieced together so far:

 

function onLoad() {

var actend = g_form.getValue('work_end') ;
var origend = g_form.getValue('u_original_end_date') ;

 

//how do i calculate if 30 days after "opend_at" to then  then :

 

g_form.setReadOnly("u_original_end_date",true);

 

//but if 30 days have past since the value "opend_at" AND the "u_original_end_date" is empty do this

 

if(origend== null || origend== undefined) )
{
g_form.setValue('u_original_end_date',actend);
g_form.setReadOnly('u_original_end_date',true);
}
}

 

Thanks!

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

If you need to lock it down completely , on form and list both then do it via ACL and not on Client script/ui policy.

 

If you use ACL in same way, but if you insist on using a client side api then you an use UI policy and add the condition as below 

AnuragTripathi_0-1700142276408.png

 

 

-Anurag

View solution in original post

2 REPLIES 2

Anurag Tripathi
Mega Patron
Mega Patron

If you need to lock it down completely , on form and list both then do it via ACL and not on Client script/ui policy.

 

If you use ACL in same way, but if you insist on using a client side api then you an use UI policy and add the condition as below 

AnuragTripathi_0-1700142276408.png

 

 

-Anurag

FredrikT
Tera Guru

This ACL fulfilled the acceptance criteria:

FredrikT_0-1701184521269.png