The Zurich release has arrived! Interested in new features and functionalities? Click here for more

A new business rule was inserted on the sys_user table with Yokohama Patch 5. KB2310555

BanuMahalakshmi
Tera Contributor

Hi,

A new business rule was inserted on the sys_user table with Yokohama Patch 5. The BR is called "Prevent invalid country code" and has a sys_id of 7cf7a7941bdc0c1ce19fb91bcd4bcbf2. This is causing an issue with updating users all of a sudden. If a user has an invalid Country value, all of a sudden no updates can occur on the user until this is corrected. I have update prevent invalid country code script but it didnt work.. still import sets failed to run. below is the script i tried:

            (function executeRule(current, previous /*null when async*/) {

    var country = current.country;
    var coreCountryGR = new GlideRecord("core_country");
    coreCountryGR.addQuery("iso3166_2", country).addOrCondition("sys_id", country);
   //coreCountryGR.addQuery("iso3166_2", country).addOrCondition("iso3166_3", country); (second way which i tried)
    coreCountryGR.query();
 
    if(coreCountryGR.getRowCount() == 0) {
        gs.warn("Attempt to insert/update an invalid value for sys_user.country: " + country);
        current.setAbortAction(true);
    }
Pls let me know suggestion to fix this issue. Thanks.
9 REPLIES 9

Bert_c1
Kilo Patron

The BR runs when the 'country' field is not empty. If supplied it must match one in the core_country table. and in my instance, there are choices defined for that field making it hard to use an invalid value.  In-activate that BR until the source of the updates uses values for that field that match records in the core_company table.  the OOB script has:

(function executeRule(current, previous /*null when async*/) {

	var country = current.country;
	var coreCountryGR = new GlideRecord("core_country");
	coreCountryGR.addQuery("iso3166_2", country);
	coreCountryGR.query();
	if(coreCountryGR.getRowCount() == 0) {
             gs.warn("Attempt to insert/update an invalid value for sys_user.country: " + country);
            current.setAbortAction(true);
	}

})(current, previous);

 

Nikhil Bajaj9
Tera Sage

Hi @BanuMahalakshmi ,

 

Check this thread for the same issue :- https://www.servicenow.com/community/upgrades-and-patching-forum/new-business-rule-on-user-table-in-...

 

If my answer helped you, please mark it- solution accepted. 

 

Regards,

Nikhil Bajaj

Please appreciate my efforts, help and support extended to you by clicking on – “Accept as Solution”; button under my answer. It will motivate me to help others as well.
Regards,
Nikhil Bajaj

Bhuvan
Kilo Patron

@BanuMahalakshmi 

 

Make sure the source system sends valid country codes in the payload [ISO 3166-1 alpha-2 code]. Incoming data is validated against core_country table in ServiceNow for Country field and when it does not find the country code, insert operation fails and it is aborted.

Bhuvan_1-1756428006235.png

Bhuvan_3-1756428051138.png

Refer below knowledge article for this known error,

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB2310555

 

You can over-ride this behavior by disabling abort operation or making the BR inactive but it is not best practices and not recommended as this BR is put in place for a reason and is needed for maintaining data quality and valid reference if used in other related tables [for example, dashboard to show number of users based on location]

 

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

@BanuMahalakshmi 

 

Did you get a chance to review this ?

 

If my response helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan

Ankur Bawiskar
Tera Patron
Tera Patron

@BanuMahalakshmi 

If you are not receiving this details from LDAP and this is causing issue then you are safe to Deactivate this business rule as this was newly added.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader