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

Swapna Abburi
Mega Sage
Mega Sage

Hi @BanuMahalakshmi 

The OOTB Country field on User table is a choice field with 2 digit country codes as choice values. Was it updated as reference type in your instance?

if it is a reference field, then your script should work. 

 

No, i didnt update as reference field. its choice field type only. pls suggest - if i update this field type as reference, which table should i call to fetch country code values?

'core_country'

Bert_c1
Kilo Patron

I don't see such a BR defined for sys_user in my PDI: yokohama-12-18-2024__patch3-04-17-2025_04-30-2025_1345.  I would just delete it. the line:

 

'    coreCountryGR.addQuery("iso3166_2", .country).addOrCondition("sys_id", country);'

is suspect as a country field value won't contain a sys_id, it is defined as a String with length 3 on sys_user table. If you want it to work, change the commented out line:

 

"coreCountryGR.addQuery("iso3166_2", country).addOrCondition("iso3166_3", country);"

to

var queryStr = ''iso3166_2='+current.country+'^ORiso3166_3='+current.country;

coreCountryGR.addEncodedQuery(queryStr);

 

try the following in Scripts - background:

var usr = new GlideRecord('sys_user');
usr.addQuery('country', '!=', '');
usr.query();
while (usr.next()) {
	gs.info('User: ' + usr.user_name + ', country: ' + usr.country);
	var cc = new GlideRecord('core_country');
	var queryStr = 'iso3166_2='+usr.country+'^ORiso3166_3='+usr.country;
	cc.addEncodedQuery(queryStr);
	cc.query();
	if(cc.next()) {
		gs.info('The country is ' + cc.name);
	}
}

 

I have read the KB2310555 and see that is related to LDAP Import. I would not expect that BR to run for updates via the UI, I'll review the BR after my instance upgrades.