Update WorkNotes

SnowUser09
Tera Contributor

I am trying to update comments in worknotes of existing problem record. Using the below posted command. 

var problem=new GlideRecord('problem');
problem.addQuery('cmdb_ci',ci);
 problem.addActiveQuery();
problem.query();
if(problem.next())
{ problem.work_notes="Problem Reviewed";  //this is not working
  problem.update();}
 
This query is not working, not able to update worknotes in existing problem record with "problem.work_notes="Problem Reviewed";".
But when I am trying to create a new problem record with below query, same command is working.
problem.initialize();
problem.assignment_group=grp;
problem.work_notes = "Problem Created & Reviewed";  //it is working
problem.insert();
 
Can anyone please check and update as how to update worknotes in existing problem record
1 ACCEPTED SOLUTION

Satyapriya
Mega Sage
Just Try This one:
BR  for incident table
var prblm=new GlideRecord('problem');
prblm.addActiveQuery();
prblm.addQuery('cmdb_ci',current.cmdb_ci);
prblm.query();
while(prblm.next()){
 prblm.work_notes='Problem Reviewed'; 
  prblm.update();
}

View solution in original post

3 REPLIES 3

Satyapriya
Mega Sage

Hi,

   Please let us know what is the value of ci i.e.

  problem.addQuery('cmdb_ci',ci);

Regards,

Satyapriya

SnowUser09
Tera Contributor

CI is a variable -

var ci = current.cmdb_ci; //it is in incident table, taking CI from Incident, and then checking if there is already a problem records in problem table then update the work notes, else create a new problem record. script is working fine except one thing- that we are not able to update worknotes in exisiting problem record.. 
to test, I even published a info message with problem.number.. even that is working. 

Satyapriya
Mega Sage
Just Try This one:
BR  for incident table
var prblm=new GlideRecord('problem');
prblm.addActiveQuery();
prblm.addQuery('cmdb_ci',current.cmdb_ci);
prblm.query();
while(prblm.next()){
 prblm.work_notes='Problem Reviewed'; 
  prblm.update();
}