Service Desk Practitioners Forum
cancel

Set Priority and Assigned Workgroup Using SP 4.5 Web API

SOLVED
Go to solution
Highlighted
Nirad
Super Contributor.

Set Priority and Assigned Workgroup Using SP 4.5 Web API

Hi All,

I am not able to set Incident Priority and workgroup using SD SP Web-Api.

I have blocked all the DB Rules as well as UI ruled to test this but still it is not working.

My code is able to create incident by setting up description, information, service, incident status etc without any error.

I am using below code to set priority:

IPriorityHome pp1=session.getPriorityHome();
String priorityText="";

IPriority [] Arr_Pri= pp1.findAllPriority();

for(i=0;i{
priorityText = Arr_Pri[i].getText();
if(priority.equals(priorityText))
{
System.out.println("Equal");
break;
}
}

incident.setPriority(Arr_Pri[i]);

I am using below code to set Workgroup:

IWorkgroupHome wg1=session.getWorkgroupHome();
String wgText="";

IWorkgroup [] Arr_wg= wg1.findAllWorkgroup();

for(i=0;i{
wgText = Arr_wg[i].getName();
if(toworkgrp.equals(wgText))
{
System.out.println("Equal");
break;
}
}

incident.getAssignment().setAssignorWorkgroup(Arr_wg[i]);



7 REPLIES
manu_
Super Contributor.

Re: Set Priority and Assigned Workgroup Using SP 4.5 Web API

Hello Nirad,

For priority I can't see a bug, assuming that you call the incident.save() after ;P

For assignment, i think i can help you:

"incident.getAssignment().setAssignorWorkgroup(Arr_wg[i]);" is wrong, I was doing it exactly the same way the first time. Assignment is an agregate object so if you want to modify it, do it like that:

IAssignment ASSignment=incident.getAssignment(); //create a new Assignment object
Assignment.setAssignorWorkgroup(Arr_wg[i]); // adding your workgroup
Assignment.transfer(); //!! APPLYING THE MODIFICATION = .save() !! if you don't do that, no modifications are saved in your assgnment.

incident.save() // of course ;)

Nirad
Super Contributor.

Re: Set Priority and Assigned Workgroup Using SP 4.5 Web API

Hi,

Thanks for the quick response.

Still it is showing blank in to workgroup field but below in More field it is transfering the workgroup.

See attached snapshot for detail.

Now i have used code sent by you as shown below of course with save() method.


IAssignment Assignment=incident.getAssignment();

IWorkgroupHome wg1 = session.getWorkgroupHome();
String wgText="";

IWorkgroup [] Arr_wg= wg1.findAllWorkgroup();

for(i=0;i{
wgText = Arr_wg[i].getName();
if(toworkgrp.equals(wgText))
{
System.out.println("Equal");
break;
}
}


Assignment.setAssignorWorkgroup(Arr_wg[i]);
Assignment.transfer();
manu_
Super Contributor.
Solution

Re: Set Priority and Assigned Workgroup Using SP 4.5 Web API

I think now it's because it's not the good method: try to use .setAssWorkgroup instead of .setAssignorWorkgroup.
Nirad
Super Contributor.

Re: Set Priority and Assigned Workgroup Using SP 4.5 Web API

Thanks a lot Manu.

It is working absolutely fine now. see the code i am using to Assign workgroup to the incident at the time of creation.


IAssignment Assignment=incident.getAssignment();

IWorkgroupHome wg1 = session.getWorkgroupHome();
String wgText="";

IWorkgroup [] Arr_wg= wg1.findAllWorkgroup();

for(i=0;i{
wgText = Arr_wg[i].getName();
if(toworkgrp.equals(wgText))
{
System.out.println("Equal");
break;
}

}


Assignment.setAssWorkgroup(Arr_wg[i]);
Assignment.transfer();

Thanks Again. If possible Please try to guide me in how to set prority because i am able to change priority of already created ticket.

But when i am using the same code to assign priority at the time of ticket creation it is giving me the problem.

Any clue on this?
manu_
Super Contributor.

Re: Set Priority and Assigned Workgroup Using SP 4.5 Web API

That's a good news.

For priority, I remember that i have to set it up once in my Web-API program and it was working only if I do the following operations in this order:

setting first the incident Impact
setting the field Priority
save the incident.

and with no DBrule ou UIrule activated, as you.

So maybe you can try that even if it's a bit strange. Can you try also to create manually incident with the form to set priority and see if other fields have an impact on it ?
Nirad
Super Contributor.

Re: Set Priority and Assigned Workgroup Using SP 4.5 Web API

Hi Manu,

Actually impact is not mandatory in my template but after choosing the priority it is populating Resolution deadline and duration field.

May be this will the root cause of this issue !!

Let me try removing this auto population and see the result.

Thanks again for quick response
manu_
Super Contributor.

Re: Set Priority and Assigned Workgroup Using SP 4.5 Web API

ok, it's an out of the box function, i was not sure. You have to fill all impacted field to set the Priority. For deadline field, you should follow what is define in your SLA if you want to set it with no errors.