Create a Problem from Incident UI action issue copying INC assignment group

davematz
Giga Expert

I am unable to get my NOW Learning task to complete successfully.

I need to create a new problem from an incident with all necessary information.  The following fields should be copied from an incident when a new problem is created from an incident: Configuration item, Priority, Assignment group, Short Description, Description.

The OOTB has all configured except the assignment group.  I've tried modifying the Script for the Create Problem (incident table) UI Action.  I added a line:

prob.assignment_group == current.assignment_group; 

this gives me an error "Expected an assignment or function call and instead saw an expression.  I understand the error message, but don't know what I needed to do to get the correct answer to solving this task.

Please instruct me on what the correct answer is and why so I can understand and learn.

Thank you

15 REPLIES 15

Prateek kumar
Mega Sage

Try this

prob.assignment_group = current.assignment_group; 


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

where do I add this at (before/after which line)?

do I only add what you suggested and that's it or do I need to add any other lines?

Try this

getProblemFromIncident: function(current) {
if(!current.isValidRecord())
return undefined;

var fieldsToBeCopiedFromIncident = [];
var prob = new GlideRecord("problem");

var record = new GlideRecord('sys_properties');
record.addQuery('name', 'com.snc.problem.create_from_incident.attributes');
record.query();

if(record.next())
fieldsToBeCopiedFromIncident = this.getCsvValue(record.value);

for(var i = 0; i < fieldsToBeCopiedFromIncident.length; i++) {
if(fieldsToBeCopiedFromIncident[i] === 'number' && prob.isValidField("first_reported_by_task"))
prob.first_reported_by_task = current.getUniqueValue();

else if (fieldsToBeCopiedFromIncident[i] === 'category') {
var elCategory = prob.getElement("category");
var choicesCategory = elCategory.getChoices();
if ( choicesCategory && choicesCategory.indexOf(current.category) >= 0 )
prob.category = current.category;

} else if (fieldsToBeCopiedFromIncident[i] === 'subcategory') {
var elSubcategory = prob.getElement("subcategory");
var choicesSubcategory = elSubcategory.getChoices(current.category);
if ( choicesSubcategory && choicesSubcategory.indexOf(current.subcategory) >=0 )
prob.subcategory = current.subcategory;

} else if (prob.isValidField(fieldsToBeCopiedFromIncident[i])) {
prob[fieldsToBeCopiedFromIncident[i]] = current[fieldsToBeCopiedFromIncident[i]];

} else {
gs.addErrorMessage(gs.getMessage("{0} is not a valid field in Problem", fieldsToBeCopiedFromIncident[i]));
return undefined;
}
prob.assignment_group = current.assignment_group;
}
return prob;
},

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

I am not able to make the change in the Script Include...system is telling me "The item is read-only based on its protection policy"

I can't tell if this is because of needing elevated privileges or not?  If so, I can't figure out how to get that to work either because I have several other tasks that I can't figure out because of that too.

I'm trying to resolve a few incomplete tasks from the NOW Learning simulator a day since I've made my attempts and have only been able to complete or partially complete 85% of the simulator.

Jyothi3
Kilo Contributor

just insert required field values(assignment_group,priority,description,short_description,cmdb_ci) in "com.snc.problem.create_from_incident.attributes" system properties list..