UI action button not working properly.

Pallavi65
Tera Contributor

Hello all,

 

Good evening.

I have created a button on Incident form.

UI action name: Escalate

So, the user should be able to click the button only twice.

SO, I have created a field "Escalation count" (u_escalation_count) of type integer on the Incident form.

So, once the user clicks on the button for the first time, the count has to be updated by 1. 

When the user clicks the button for the second time, then count has to be updated by 2.

For this I have written a code, but the problem is,

The count is getting updated with 1 for the first time, but the second time, the value is updating with 2 but when I refresh the form, the value is again getting back to 1.

 

Please help me.

My Code:

function doEscalate(){
   
    var ec = g_form.getValue('u_escalate_count');
    if(ec==0){      
        g_form.setValue('u_escalate_count',1);  
    }
    else if(ec==1){        
        g_form.setValue('u_escalate_count',2);
            }

    gsftSubmit(null,g_form.getFormElement(),'escalate_now');
}

if(typeof window == 'undefined')
setRedirect();
function setRedirect(){
    //current.u_escalate_count = ec;
    current.update();
    action.setRedirectURL(current);
}
 
 
Regards,
Pallavi
1 ACCEPTED SOLUTION

The following worked for me.

 

 

 

 

function doEscalate(){
    var ec = g_form.getValue('u_escalate_count');
	alert('doEscalate: ec = ' + ec);
    if(ec==0){      
        g_form.setValue('u_escalate_count',1);  
    }
    else if(ec==1){        
        g_form.setValue('u_escalate_count',2);
     }
	alert('doEscalate: submitting record, u_escalation_count = ' + g_form.getValue('u_escalation_count'));
    g_form.submit();
    current.update();
    action.setRedirectURL(current);
}

 

 

That is, if the default value of your custom field is 0. If null, it doesn't work.

 

View solution in original post

6 REPLIES 6

The following worked for me.

 

 

 

 

function doEscalate(){
    var ec = g_form.getValue('u_escalate_count');
	alert('doEscalate: ec = ' + ec);
    if(ec==0){      
        g_form.setValue('u_escalate_count',1);  
    }
    else if(ec==1){        
        g_form.setValue('u_escalate_count',2);
     }
	alert('doEscalate: submitting record, u_escalation_count = ' + g_form.getValue('u_escalation_count'));
    g_form.submit();
    current.update();
    action.setRedirectURL(current);
}

 

 

That is, if the default value of your custom field is 0. If null, it doesn't work.

 

Thank you Bert,

It works

 

Regards,,

Pallavi