Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Duration field with date field

SOLVED
Go to solution
Highlighted
Akies
Occasional Visitor

Adding Duration field with date field

Hi,

I want to add one date field(eg: datex) with a duration field (max. duration) and putting the value to other date field.
e.g: datey = datex + max. duration.

If I try to add the value through function option in rules,I get "add timespan to" in which I can only add some predefined time to the field.
Is there any way to add two fields?

Regards,
Akhil
22 REPLIES
Michael Lutfi
Frequent Visitor

Re: Adding Duration field with date field

yes using web-api you can develop a class that will handle that funciton for you and call it from a DB rule
Akies
Occasional Visitor

Re: Adding Duration field with date field

Hi,

No result found.Can anyone help?
I am weak on web-api.Is there any other solution?

Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

Hi
This class for calculation with SL.
Enjoy,
Vassili
Akies
Occasional Visitor

Re: Adding Duration field with date field

Hi Vassilli,

I tried to execute the java file using javac command in "C:\jdk1.3.1_03\bin" where I copied your java file but I got following error:

C:\jdk1.3.1_03\bin>javac ReactionTimeCalculation.java
ReactionTimeCalculation.java:8: cannot resolve symbol
symbol : class ApiSDSession
location: package api
import com.hp.itsm.api.ApiSDSession;
^
ReactionTimeCalculation.java:9: cannot resolve symbol
symbol : class IServicecall
location: package interfaces
import com.hp.itsm.api.interfaces.IServicecall;
^
ReactionTimeCalculation.java:10: cannot resolve symbol
symbol : class IServiceLevel
location: package interfaces
import com.hp.itsm.api.interfaces.IServiceLevel;
^
ReactionTimeCalculation.java:11: cannot resolve symbol
symbol : class ISupportHours
location: package interfaces
import com.hp.itsm.api.interfaces.ISupportHours;
^
ReactionTimeCalculation.java:12: cannot resolve symbol
symbol : class ApiDateUtils
location: package util
import com.hp.ifc.util.ApiDateUtils;
^
ReactionTimeCalculation.java:27: cannot resolve symbol
symbol : class ApiSDSession
location: class ReactionTimeCalculation
private ApiSDSession session;
^
ReactionTimeCalculation.java:28: cannot resolve symbol
symbol : class IServicecall
location: class ReactionTimeCalculation
private IServicecall sc;
^
ReactionTimeCalculation.java:43: cannot resolve symbol
symbol : variable ApiSDSession
location: class ReactionTimeCalculation
session = ApiSDSession.openSession(server, login, passw);
^
ReactionTimeCalculation.java:51: cannot resolve symbol
symbol : variable ApiSDSession
location: class ReactionTimeCalculation
session = ApiSDSession.openSession(server, login+"1", passw);
^
ReactionTimeCalculation.java:60: cannot resolve symbol
symbol : variable ApiSDSession
location: class ReactionTimeCalculation
session = ApiSDSession.openSession(server, login+"2", passw);
^
ReactionTimeCalculation.java:74: cannot resolve symbol
symbol : class IServiceLevel
location: class ReactionTimeCalculation
IServiceLevel sl = sc.getServiceLevel();
^
ReactionTimeCalculation.java:75: cannot resolve symbol
symbol : class ISupportHours
location: class ReactionTimeCalculation
ISupportHours sh[] = sl.getSupportHours();
^
ReactionTimeCalculation.java:85: cannot resolve symbol
symbol : variable ApiDateUtils
location: class ReactionTimeCalculation
crDate = ApiDateUtils.double2Date(new Double(cDay));
^
ReactionTimeCalculation.java:205: cannot resolve symbol
symbol : variable ApiDateUtils
location: class ReactionTimeCalculation
crDate = ApiDateUtils.double2Date(new Double(result));
^
ReactionTimeCalculation.java:207: cannot resolve symbol
symbol : variable ApiDateUtils
location: class ReactionTimeCalculation
day2.setTime(ApiDateUtils.double2Date(new Double(result)));
^
ReactionTimeCalculation.java:215: cannot resolve symbol
symbol : variable ApiDateUtils
location: class ReactionTimeCalculation
if(debug) System.out.println(ApiDateUtils.double2Date(new Doubl
sult)));

Do I need to use some api?? where can I get that? and where and how to execute your file?

Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

HI
you must use -classpath web-api.jar;. Bt this class for over tast - calculate "reaction time" , beliave you must corret that for your task.

Vassili
Akies
Occasional Visitor

Re: Adding Duration field with date field

Hi Vissili,

I am thankful for your support but as I already told you that I am weak in java programming.What I tried to do with your java file is , on command prompt, I went to "C:\jdk1.3.1_03\bin" path and used "javac -classpath web-api.jar;. AutoClose.java" file.I got a number of errors then I copied web-api.jar file from "C:\Program Files\Hewlett-Packard\OpenView\service desk 4.5\service pages\webapps\sd-sp45\WEB-INF\lib" to this location and then executed above command.Now I got 7 errors as explained below:

C:\jdk1.3.1_03\bin>javac -classpath web-api.jar; AutoClose.java
AutoClose.java:24: cannot resolve symbol
symbol : class IServicecallHome
location: class AutoClose
IServicecallHome scHome = session.getServicecallHome();
^
AutoClose.java:25: cannot resolve symbol
symbol : class IServicecallWhere
location: class AutoClose
IServicecallWhere scWhere = scHome.createServicecallWhere();
^
AutoClose.java:33: cannot resolve symbol
symbol : class IStatusServicecallHome
location: class AutoClose
IStatusServicecallHome sscHome = session.getStatusServicecallHome();
^
AutoClose.java:35: cannot resolve symbol
symbol : class IStatusServicecallWhere
location: class AutoClose
IStatusServicecallWhere sscWhere = sscHome.createStatusServicecallWhere();
^
AutoClose.java:37: cannot resolve symbol
symbol : class IStatusServicecall
location: class AutoClose
IStatusServicecall[] ssc = sscHome.findStatusServicecall(sscWhere);
^
AutoClose.java:38: cannot resolve symbol
symbol : class IStatusServicecall
location: class AutoClose
IStatusServicecall resolvedStatus=ssc[0];
^
AutoClose.java:43: cannot resolve symbol
symbol : class IStatusServicecall
location: class AutoClose
IStatusServicecall closedStatus=ssc[0];
^
7 errors

I know this java file was not sent by you but I think this is the general error I am getting.Am I missing something??

Pls find the attached AutoClose.java file I am trying to execute.

Regards,
Akhil
Akies
Occasional Visitor

Re: Adding Duration field with date field

Hey friend!!

I got my class file.Now can you help me what paramenters I should use to run that class file on command prompt??

I first want to execute this class file through cmd prompt and then try to use through SD..

suppose my server is having ip: a.a.a.a
username: akhil
password: akhil

on what location I should execute this file??

Kindly help..

Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

ok.
please send me name of feilds what are you lika summary, name must be as that exist in db, then I prepare for you class, that will be more quickly :).

Vassili
Akies
Occasional Visitor

Re: Adding Duration field with date field

Hi Vissili,

Thanks as lot man!!!

Well let me explain you what I want..I have a status called waiting for user availability and pending for form approval.I can calculate 2 duration field's values.The name of these fields are dur1 and dur2.
Now when status is "Completed", I want to trigger a UI rule that should set Deadline=Deadline+dur1+dur2.

Request you to kindly provide a solution for the same..

Regards,
Akhil
Vasily Kamenev
Honored Contributor
Solution

Re: Adding Duration field with date field

I'd like so you send me the name of feils what are you will use, exaple:
on Screen form i see that field as "reaction" but real key "ServicecallDate1", so describe each your fields in task

Vassili
Akies
Occasional Visitor

Re: Adding Duration field with date field

Hi,

For dur1, field name is SerDuration1
For dur2, field name is SerDuration2
For Deadline, field name is Deadline

Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

Hi
compile this file, must work.

V.
Akies
Occasional Visitor

Re: Adding Duration field with date field

Thanks Vassili,

I am able to create class file.Now can you tell me how can I use the same through UI rule.If you can send some snapshots for the same with parameters to be passed?

Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

HI
This class for DB rule, if you are like use in UI rule, need other update system: "Data update from External system", then result return in open form, because in DB Rule result return to Database. If you are real needed UI Rule, need have any cgi system or Tomcat, what the decission?

Vassili
Akies
Occasional Visitor

Re: Adding Duration field with date field

Hi,

Thanks fr the updates.I really want to use UI rule for the same.
Also when I tried to run the command on cmd prompt, I got following error:

E:\jdk1.3.1_03\bin>java Akhil localhost system servicedesk123 11565
Exception in thread "main" java.lang.NoClassDefFoundError: Akhil (wrong name: tr
ush/Akhil)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:488)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:10
6)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:243)
at java.net.URLClassLoader.access$100(URLClassLoader.java:51)
at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:183)
at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:281)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:310)

Can you specify where I am wrong?

Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

So, in source remove line package trush;, then recompile and run again.

Vassili
Akies
Occasional Visitor

Re: Adding Duration field with date field

This time I got following error:

E:\jdk1.3.1_03\bin>java Akhil localhost administrator hutch123 11565
Exception in thread "main" java.lang.NoClassDefFoundError: com/hp/itsm/api/inter
faces/IWorkflow


Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

oh sorry, run as java -cp web-api.jar;. ...
form your SP.

Vassili
Akies
Occasional Visitor

Re: Adding Duration field with date field

This time:

E:\jdk1.3.1_03\bin>java -cp web-api.jar;. Akhil localhost system servicedesk 11565
Exception in thread "main" java.lang.NullPointerException
at Akhil.main(Akhil.java:38)


Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

Ok, try now.

Vassili
Akies
Occasional Visitor

Re: Adding Duration field with date field

You are a genious..It worked like a magic..Now I am trying to execute the same using UI rule but don'nt know how to start since I have'nt used "data update from external system" before.
I tested by putting java -cp web-api.jar;. Akhil in the URL and localhost XXX XXX [ID] in the parameters field but got an error.

Can you explain the point to point explanation of the same?

Regards,
Akhil
Vasily Kamenev
Honored Contributor

Re: Adding Duration field with date field

Hi again.
I told you before, to open form possible return data only if using "Update from External system", I'm use Tomcat for this option, but possible use any cgi system, need create a litte other - cgi script or servlet(Tomcat) for POST procedure. What are you like(can) use for it?

V.
//Add this to "OnDomLoad" event