Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

counter field on incident form

sonita
Giga Guru

in my incident form I have a date type field called : Projected Fix Implementation Date

I have a field which is called :Implementation Date Changed Count and actually this field acts as a counter which means:

when the Projected Fix Implementation Date is changed , the counter will be incremented.

What I'm thinking to do is to create a script include and use glide ajax on my client script ; but I need some help:

This is my on change client script so far and i still haven't worked on the script include:

I'd appreciate it if you can correct me:

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

    if (isLoading || newValue == '') {

          return;

    }

    var projected_date = g_form.getValue('u_fix_implementation_date');

    var ajax = new GlideAjax('AjaxCounterField');

    ajax.addParam('sysparm_name','ContCalc');

  ajax.addParam('sysparm_pr_date',pr_date);

  ajax.getXMLWait();

    var answer = ajax.getAnswer();

  g_form.setValue('u_implementation_date_changed_', answer);

}

1 ACCEPTED SOLUTION

SME
Giga Guru

I am not sure why you want to complicate things by writing a script include and doing an ajax call...


Craete a business rule similar to OOB "reassignment counter" BR on incident table.


Can you not write a before update business rule and do something like this :-



var counter = current.u_implementation_date_changed_; //If this an integer field


if(current.u_fix_implementation_date.changes())


  counter++;


current.u_implementation_date_changed_ = counter;


View solution in original post

4 REPLIES 4

SME
Giga Guru

I am not sure why you want to complicate things by writing a script include and doing an ajax call...


Craete a business rule similar to OOB "reassignment counter" BR on incident table.


Can you not write a before update business rule and do something like this :-



var counter = current.u_implementation_date_changed_; //If this an integer field


if(current.u_fix_implementation_date.changes())


  counter++;


current.u_implementation_date_changed_ = counter;


So I can just create a business rule for that? Thanks for your help!


Yes. Only a BR. Check that OOB "reassignment counter" on incident table...



No problem.


Hi mansi, I have a question regarding catalog task notifications. What's


your email address??


On Mar 31, 2016 3:23 PM, "manapt25" <community-no-reply@servicenow.com>