Service Desk Practitioners Forum
cancel

Relating Change and Service Call

Highlighted
Stefan Sagstett
Trusted Contributor.

Relating Change and Service Call

Hello,

I'm automatically creating Changes out of Service Calls by using DB-Rule and SD-Event and a Image Mapping. My problem is, that Service Call and Change are not related then.

I already read http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=808712, but was not able to gain the right information for me.

Could anyone please give me advice how to relate those automatically???

Thanks in advance.

Stefan
2 REPLIES
Stefan Sagstett
Trusted Contributor.

Re: Relating Change and Service Call

Well, I tried several ways I read in other treads but with no success. My way now looks like the following ... but it doesn't work yet. For illustration: When the jsp for generating the Servicecall is sent I forward to another jsp, that should create the relation between Servicecall and Change. I then search for the right Servicecall and Change by their IDs, which works fine, but then ... how to go on?

Perhaps someone can help me???

// Search Change
IChangeHome changeHome = bean.sd_session().getChangeHome();
IChangeWhere changeWhere = changeHome.createChangeWhere();
changeWhere.addCriteriumOnChaShorttext3(scOID);
IChange ch[] = changeHome.findChange(changeWhere);

// Search Servicecall
Long scID = new Long(scOID);
IServicecallHome scHomeRel = bean.sd_session().getServicecallHome();
IServicecallWhere scWhereRel = scHomeRel.createServicecallWhere();
scWhereRel.addCriteriumOnID(scID);
IServicecall scRel[] = scHomeRel.findServicecall(scWhereRel);

// Create Service Event Relation
IServiceEventRelationEntryHome sereHome = bean.sd_session().getServiceEventRelationEntryHome();
IServiceEventRelationEntryWhere sereWhere = sereHome.createServiceEventRelationEntryWhere();
IServiceEventRelationTypeHome sertHome = bean.sd_session().getServiceEventRelationTypeHome();
IServiceEventRelationTypeWhere sertWhere = sertHome.createServiceEventRelationTypeWhere();

IServiceEventRelationEntry sere = sereHome.openNewServiceEventRelationEntry();
IServiceEventRelationType sert = sertHome.openNewServiceEventRelationType();

// Ordering for Caused by
Integer serOrd = new Integer(10);
sert.setOrdering(serOrd);

// set relation attributes
sere.setServicecall(scRel[0]);
sere.setChange(ch[0]);
sere.setRelationType(sert);
sere.setReverseRelationType(sert)

// add Relation
ch[0].addServiceEventRelation(sere);
Stefan Sagstett
Trusted Contributor.

Re: Relating Change and Service Call

Due to help of Barbara in thread
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1017781
I now got the solution for my relation problem.

Here my new and working code:
// Create Service Event Relation
IServiceEventRelationType vRelationType = null;
IServiceEventRelationTypeHome vRelationTypeHome = null;
IServiceEventRelationTypeWhere vRelationTypeWhere = null;
IServiceEventRelationEntryHome vRelationEntryHome = null;
IServiceEventRelationEntry vRelationEntry = null;

//Relation type caused by
vRelationTypeHome = bean.sd_session().getServiceEventRelationTypeHome();
vRelationTypeWhere = vRelationTypeHome.createServiceEventRelationTypeWhere();
vRelationTypeWhere.addContainCriteriumOnText("Caused by");
vRelationType = vRelationTypeHome.findServiceEventRelationType(vRelationTypeWhere)[0];

//Create relation entry
vRelationEntryHome = bean.sd_session().getServiceEventRelationEntryHome();
vRelationEntry = vRelationEntryHome.openNewServiceEventRelationEntry();
vRelationEntry.setChange(chRel[0]);
vRelationEntry.setServicecall(scRel[0]);
vRelationEntry.setRelationType(vRelationType);
vRelationEntry.save();