Skip to main content

SERVICENOW Improving the prevent duplicate number business rule - unique numbering / prevent duplicate number

SERVICENOW Improving the prevent duplicate number business rule - unique numbering / prevent duplicate number

new reference - search on enforcing unique numbering

https://docs.servicenow.com/bundle/xanadu-platform-administration/page/administer/field-administration/concept/c_EnforcingUniqueNumbering.html

---

old reference:


 as per the approach here:

https://docs.servicenow.com/bundle/paris-platform-administration/page/administer/field-administration/concept/c_EnforcingUniqueNumbering.html?cshalt=yes

here is a slightly improved version of the bus rule

description:

use this script to test:
/*var grInc=new GlideRecord('incident');
grInc.newRecord();
grInc.short_description='test RDS';
grInc.number='INC5150xxx'; //--an existing number
gs.print(grInc.insert());*/

script:

(function executeRule(current, previous /*null when async*/ ) { //var curNum = current.number + ''; var curNum = current.getValue('number'); if (curNum) { var recordClass = current.getRecordClassName(); var now_GR = new GlideRecord(recordClass); now_GR.addQuery('number', curNum); now_GR.query(); if (now_GR.getRowCount() > 0) { var newNum = getNextObjNumberPadded(); //gs.addInfoMessage("The number " + current.number + " was already used by another " + //recordClass + ". The " + recordClass + " number has been changed to " + //newNum); var sFeedback = gs.getMessage("The number {0} was already used by another {1}. The {1} number has been changed to {2}", [ current.number, recordClass, newNum ]); gs.addInfoMessage(sFeedback); //current.number = newNum; current.setValue('number', newNum); } } })(current, previous);

Comments

  1. I admire this article for the well-researched content and excellent wording. second phone number line2 app services. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.

    ReplyDelete
  2. I always check this type of advisory post and I found your article which is related to my interest. This is a great way to increase knowledge for us. Thanks for sharing an article like this.Enterprise Wireless Solutions

    ReplyDelete
  3. You have provided valuable data for us. It is great and informative for everyone. Read more info about at&t tv and internet service usa Keep posting always. I am very thankful to you.

    ReplyDelete
  4. I just need to say this is a well-informed article which you have shared here about hoodies.Business Phone System South Carolina It is an engaging and gainful article for us. Continue imparting this sort of info, Thanks to you.

    ReplyDelete
  5. You have done good work by publishing this article here.Virtual Number UAE I found this article too much informative, and also it is beneficial to enhance our knowledge. Grateful to you for sharing an article like this.

    ReplyDelete
  6. Make sure you know when your card expires since some cards have the option of having their expiration dates extended. SIM Card for IoT

    ReplyDelete

Post a Comment

Popular posts from this blog

ServiceNow check for null or nil or empty (or not)

Haven't tested these all recently within global/local scopes, so feel free to have a play! option 1 use an encoded query embedded in the GlideRecord , e.g.  var grProf = new GlideRecord ( 'x_cls_clear_skye_i_profile' ); grProf . addQuery ( 'status=1^ owner=NULL ' ); grProf . query (); even better use the glideRecord  addNotNullQuery or addNullQuery option 2 JSUtil.nil / notNil (this might be the most powerful. See this link ) example: if ( current . operation () == 'insert' && JSUtil . notNil ( current . parent ) && ! current . work_effort . nil ())  option 3 there might be times when you need to get inside the GlideRecord and perform the check there, for example if the code goes down 2 optional routes depending on null / not null can use gs.nil : var grAppr = new GlideRecord ( 'sysapproval_approver' ); var grUser = new GlideRecord ( 'sys_user' ); if ( grUser . get ( 'sys_id' , current . approver )){

Service Catalog: variable advanced reference qualifiers

Call a script include to apply a reference qualifier on a catalog item variable: - variable reference qualifier dependent on another variable selection, in this case a variable referencing sys_user (requested_for) On the catalog item form. variable name to apply ref qual filter : retail_equipment variable reference qualifier (on cmdb table ): javascript : new  refqual_functions (). lostStolen_getAssignedCIs (); client-callable script include ( refqual_functions)  function : lostStolen_getAssignedCIs : function (){         //--called from variable set client script, for lost/stolen request (service catalog)     gs . log ( current . variables . requested_for , 'retail_lostStolen_getAssignedCIs' );         return ( 'install_statusNOT IN8,7^owned_by=' + current . variables . requested_for );             //owned_by=1269b79937f1060041c5616043990e41^install_statusNOT IN8,7            },

Get URL Parameter - server side script (portal or classic UI)

Classic UI : var sURL_editparam = gs . action . getGlideURI (). getMap (). get ( ' sysparm_aparameter ' ); if ( sURL_editparam == 'true' ) { gs . addInfoMessage ( 'parameter passed ); } Portal : var sURL_editparam = $sp . getParameter ( " sysparm_aparameter " ); if ( sURL_editparam == 'true' ) { gs . addInfoMessage ( 'parameter passed ); }