Service Desk Practitioners Forum
cancel

Template id

SOLVED
Go to solution
Highlighted
SriniKasyap
Valued Contributor.

Template id

Friends, Can anyone help me in retreiving the templateid from OVSD???
I am using openNewChange(long);
long is the templateid.
Or id there anyother alternate method for that?
9 REPLIES
Vasily Kamenev
Acclaimed Contributor.
Solution

Re: Template id

hi
Use that:
SELECT ITSM_CODES_LOCALE.CDL_NAME, REP_TEMPLATES.TEM_NAME, REP_TEMPLATES.TEM_OID
FROM ITSM_CODES_LOCALE RIGHT OUTER JOIN
REP_TEMPLATES ON ITSM_CODES_LOCALE.CDL_COD_OID = REP_TEMPLATES.TEM_CAT_OID
ORDER BY ITSM_CODES_LOCALE.CDL_NAME, REP_TEMPLATES.TEM_NAME

Vasily
SriniKasyap
Valued Contributor.

Re: Template id

Thanks for your time vasily, but what i want is, the templateid, of type long to create a template using java code.
Vasily Kamenev
Acclaimed Contributor.

Re: Template id

That the same id(oid). If you like searching by Java code - use:
ITemplateWhere twhere = session.getTemplateHome().createTemplateWhere();
twhere.addCriteriumOnName("My Template");
ITemplate templ[] = session.getTemplateHome().findTemplate(twhere);

Vasily
SriniKasyap
Valued Contributor.

Re: Template id

HI Vasily, i have used the same lines,

ITemplateHome itemp = session.getTemplateHome();
ITemplateWhere objItempWhr = itemp.createTemplateWhere();
objItempWhr.addCriteriumOnName("MY TEMPL");
ITemplate[] Itemp = itemp.findTemplate(objItempWhr);
if (Itemp == null)
System.out.println("Null");
else
System.out.println("Template exists");


But may i know by doing this if it will be added? or is there anyother statement to add it to the new change i create?
Thanks for your time.
Vasily Kamenev
Acclaimed Contributor.

Re: Template id

use next:
openNewChange(templ[0].getOID());

Vasily
SriniKasyap
Valued Contributor.

Re: Template id

I am using
IChange objChange = objChangeHome.openNewChange();
so still do i use this statement to add the template, or replace this statement with the one u sent me?

Thanks again
SriniKasyap
Valued Contributor.

Re: Template id

Thanks a lot VAsily, it works fine.

ITemplateHome itemp = session.getTemplateHome();
ITemplateWhere objItempWhr = itemp.createTemplateWhere();
objItempWhr.addCriteriumOnName("GM-GSC09-Normal Change");
ITemplate[] Itemp = itemp.findTemplate(objItempWhr);
if (Itemp == null)
System.out.println("Null");
else
System.out.println("Temp exists");
templateID=(Itemp[0].getOID());
IChange objChange = objChangeHome.openNewChange(templateID);
System.out.println("Change Created");
System.out.println(objChange.getTemplate().getName());

Srini
Vasily Kamenev
Acclaimed Contributor.

Re: Template id

com.â hp.â itsm.â api.â interfaces.â IChangeHome
public IChange openNewChange(Long arg0)
Open a new Change, using a template

Parameters:
template - The template of which the values are used

session.getChangeHome().openNewChange(templ[0].getOID());

Vasily
SriniKasyap
Valued Contributor.

Re: Template id

Thanks a lot to Vasily, without whom i would have been endlessly working on this api.