Service Desk Practitioners Forum
cancel

Delete Service call relating to Problem

Highlighted
Barbara_38
Valued Contributor.

Delete Service call relating to Problem

Hello, Friends!

I have a situation for you.

I have implemented a code for creating a sc via web api from a problem, and relation between the service calls and problems. It worked well. But now I must delete service calls relating with a problem.
Someone can give me a solution for this?

Any reply will be appreciated.
Barbara
5 REPLIES
Vasily Kamenev
Acclaimed Contributor.

Re: Delete Service call relating to Problem

Hello Barbara.
Not see a problem in deleting SC, delete SC and PR is still be in your DB, if You like delete together SC+PR, use one custom field or status, how like, "mark for delete" and create two DB rule. in SC if "mark for delete" = true, action Update use Select Related item , update one fields in PR or Status to "mark for delete" and second Action Exec you new web api code - where a simple function delete SC. 2-nd rule in PR if "mark for delete" = true, action exec you new web api code - where a simple function delete PR.

Vassili
Stefan Sagstett
Trusted Contributor.

Re: Delete Service call relating to Problem

Hi Barbara,

I'm dealing with the problem that I'm not able to create relations between servicecalls and changes, which should be similar to relations between servicecalls and problems.
I already opened a thread with my code, but with no success.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1016607

It would be really nice of you, if you could send me an extraction of your code concerning the relation.

Stefan

P.S. Sorry, this is not really helpful for your problem.
Barbara_38
Valued Contributor.

Re: Delete Service call relating to Problem

I have written the following code:
***********************************
IProblemHome pr_hm = bean.sd_session().getProblemHome();
IProblem problem = pr_hm.openProblem(Long.parseLong(_problem_id));
IServiceEventRelationEntry[] sc_rel = problem.getServiceEventRelations();
if (sc_rel.length==1)
{
sc_rel[0].getServicecall().delete();
}

*************************************
But the service call relating with the problem isn't deleted...

Can Help me?
Barbara_38
Valued Contributor.

Re: Delete Service call relating to Problem

Hi Stefan,
my code for creating a relation between sc and problem is the following:
IServiceEventRelationType vRelationType = null;
IServiceEventRelationTypeHome vRelationTypeHome = null;
IServiceEventRelationTypeWhere vRelationTypeWhere = null;
IServiceEventRelationEntryHome vRelationEntryHome = null;
IServiceEventRelationEntry vRelationEntry = null;

//ricerco relation type Solved by
vRelationTypeHome = bean.sd_session().getServiceEventRelationTypeHome();
vRelationTypeWhere = vRelationTypeHome.createServiceEventRelationTypeWhere();
vRelationTypeWhere.addContainCriteriumOnText("Solved by");
vRelationType = vRelationTypeHome.findServiceEventRelationType(vRelationTypeWhere)[0];

//creo la relation entry
vRelationEntryHome = bean.sd_session().getServiceEventRelationEntryHome();
vRelationEntry = vRelationEntryHome.openNewServiceEventRelationEntry();
vRelationEntry.setProblem(problem);
vRelationEntry.setServicecall(scall);
vRelationEntry.setRelationType(vRelationType);
vRelationEntry.save();
Stefan Sagstett
Trusted Contributor.

Re: Delete Service call relating to Problem

Thank you very much Barbara. Now all is clear and working perfect. If this was my thread this would be 10 pts for you.

My fault was that I wanted to do addServiceEventRelation on my IChange object. Strangly I got not the idea of just saving the IServiceEventRelationEntry.

Thank you.

Stefan