Unable to set Assignment group

Kunal33
Tera Expert

Hi Team,

 

We have a record producer in which we need to set Assignment group based on Functional identifier fields. This functional identifier field is a reference field and refer to x_bii_learning_req_functional_identifier_list table and 

x_bii_learning_req_assignment_lookup store both functional identifier and Assignment group.

 

We have created a script include:- 

 

var BIIB_Assignment_lookup = Class.create();
BIIB_Assignment_lookup.prototype = {
initialize: function() {},

getAssignmentGroup: function(functident) {
var assigngrp;
var grp = new GlideRecord("x_bii_learning_req_assignment_lookup");
grp.addQuery("active", true);
grp.addQuery("functional_identifier.full_name", functident);
//grp.addQuery('sys_id', functident);
grp.query();
if (grp.next()) {
assigngrp = grp.group;
gs.log("kunal1"+assigngrp);
}
return assigngrp;

},

type: 'BIIB_Assignment_lookup'
};

 

x_bii_learning_req_assignment_lookup- this table contains the Assignment group name and functiona identifier values.

 

and 

 

var assignmentgroup = new x_bii_learning_req.BIIB_Assignment_lookup().getAssignmentGroup(funident);
current.assignment_group = assignmentgroup;

 

We have call this in Record producer script.

 

but unable to get assignment group based on functional identifer

 
6 REPLIES 6

Anil Lande
Kilo Patron

Hi,

Are you getting the logs which you have added in the Script include function? Put more logs and trace your code, it would be helpful to find where exactly it fails.

Also I would suggest you to make small change to below part:

 

if (grp.next()) {
assigngrp = grp.group.toString();   // use toString() here to return sys_id or use assigngrp = grp.group.sys_id;
gs.log("kunal1"+assigngrp);
}

 

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Atul6
ServiceNow Employee
ServiceNow Employee

Hi Kunal,

 

You need to find out the records in "x_bii_learning_req_assignment_lookup" table based on functional identifier sysID but in your glide record query you're querying functional_identifier.full_name instead of functional_identfier. Try glide record query like grp.addQuery("functional_identifier", functident);

 

//Sample script

var assigngrp;
var grp = new GlideRecord("x_bii_learning_req_assignment_lookup");
grp.addQuery("active", true);
grp.addQuery("functional_identifier", functident);
grp.query();