Can Catalog UI Policy be restricted to only apply if the item is not closed?

mah1
Kilo Sage

Washington DC Patch 5

 

We have a catalog item with a UI policy where the date variable must be greater than the current date. If the selected date is less than or equal to the current date, the variable is cleared and an error message is displayed. This works well unless the request has been closed. Is there a way to only apply the UI policy to open items so that when we view a request item or catalog task that has been closed the actual selected date is displayed and not flagged as an error?  The date variable value for a closed request item or catalog task will most likely be a past date; in this case, we just want to see what it is.

 

Thank you

1 ACCEPTED SOLUTION

mah1
Kilo Sage

I think i figured it out. I added a check to the execute if false onCondition function of the UI Policy - if the request is open/pending/work in progress, then it displays an error message; otherwise, it sets the variables to read only.

I added a similar check to the execute if true onCondition function of the UI Policy which sets the variables to read only if the request is closed.

 

    var req = g_form.getReference('request',myData); 
    function myData(creq)
    {
        if(creq.state==1||creq.state==2||creq.state==-5){
            g_form.clearValue('rerc_proposed_install_date');
            g_form.showFieldMsg('rerc_proposed_install_date','Proposed Install Date cannot be a past date','error');            
        }
        else {
            g_form.setVariablesReadOnly(true);
        }
    }

View solution in original post

3 REPLIES 3

Abhishek_Thakur
Mega Sage

Hello @mah1 ,

 

Why don't you try to use g_form,getValue("fieldname")

if(fieldname=="fieldname"){

g_form,setVariableReadonly(true); // or any operation you want.

}

Thank you but I would only want to do that if the request is not active (i.e., not closed). How do I check if the request is active?

mah1
Kilo Sage

I think i figured it out. I added a check to the execute if false onCondition function of the UI Policy - if the request is open/pending/work in progress, then it displays an error message; otherwise, it sets the variables to read only.

I added a similar check to the execute if true onCondition function of the UI Policy which sets the variables to read only if the request is closed.

 

    var req = g_form.getReference('request',myData); 
    function myData(creq)
    {
        if(creq.state==1||creq.state==2||creq.state==-5){
            g_form.clearValue('rerc_proposed_install_date');
            g_form.showFieldMsg('rerc_proposed_install_date','Proposed Install Date cannot be a past date','error');            
        }
        else {
            g_form.setVariablesReadOnly(true);
        }
    }