Re: Negdatestamp in javascript to insert new activity (702 Views)
Reply
Regular Advisor
Blue_1
Posts: 161
Registered: ‎12-01-2010
Message 1 of 13 (1,527 Views)

Negdatestamp in javascript to insert new activity

Hi

 

I need to add a activity record in activitycm3r table

 

For this i have written a javascript, which succesfully creates a record, but it is not sorted. This is beacause i have not provided negdatestamp

 

how to give negdatestamp in javascript

 

please help me with code..

Please use plain text.
Honored Contributor
Abhijit K
Posts: 901
Registered: ‎10-14-2010
Message 2 of 13 (1,520 Views)

Re: Negdatestamp in javascript to insert new activity

Hi ,

 

Take a look at following script:

 

This script demonstrates calling the datetimestamp function. It selects a record from the contacts
table and updates the sysmodtime field.

 

var f = new SCFile( "contacts" );

 f.doSelect( "contact.name = \"BROWN, NICHOLAS\"" );

print( "sysmodtime was: " + f.sysmodtime );
datetimestamp( f, "sysmodtime" );
print( "sysmodtime is now: " + f.sysmodtime );

 

re,

abhijit

Please use plain text.
Regular Advisor
Blue_1
Posts: 161
Registered: ‎12-01-2010
Message 3 of 13 (1,516 Views)

Re: Negdatestamp in javascript to insert new activity

it gives me error ...datetimestamp is not a function

Please use plain text.
Honored Contributor
Piku
Posts: 3,908
Registered: ‎06-17-2010
Message 4 of 13 (1,515 Views)

Re: Negdatestamp in javascript to insert new activity

Hi,
negative date stamp is calculated as below,
negdatestamp in $L.activity='31/12/2199 21:30:00' - tod()

and for JS you have to use
negdatestamp in $L.activity='31/12/2199 21:30:00' - system.functions.tod()
but '31/12/2199 21:30:00' need to be in JS date type.


hth,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Assign Kudo, if found post useful and mark it accepted if solves the issue.
http://h30499.www3.hp.com/t5/Tips-and-Tricks/Kudos-what-where-how-and-why/m-p/5677925#U5677925
Please use plain text.
Regular Advisor
Blue_1
Posts: 161
Registered: ‎12-01-2010
Message 5 of 13 (1,511 Views)

Re: Negdatestamp in javascript to insert new activity

the problem is how to calculate the negdatestamp in java script. This is the challenging part..

Please use plain text.
Honored Contributor
Abhijit K
Posts: 901
Registered: ‎10-14-2010
Message 6 of 13 (1,490 Views)

Re: Negdatestamp in javascript to insert new activity

Hi Blue,

 

Sorry.It was for SM 9.30...

 

Could you please explain what exactly you are looking for, kind of date decrement?

 

re,

abhijit

 

Please use plain text.
Regular Advisor
Blue_1
Posts: 161
Registered: ‎12-01-2010
Message 7 of 13 (1,487 Views)

Re: Negdatestamp in javascript to insert new activity

I have created a scheduler which runs weekly to close the change records. when the changes are closed an activity record also has to be created, for this i need a negdatestamp field

 

i need to know how to calculate negdatetime in javascript..as i am using javascript in scheduler

Please use plain text.
Honored Contributor
Piku
Posts: 3,908
Registered: ‎06-17-2010
Message 8 of 13 (1,485 Views)

Re: Negdatestamp in javascript to insert new activity

check these,
http://h30499.www3.hp.com/t5/ITRC-OV-ServiceCenter-Service/Add-Activity-to-device-table/m-p/4778468/...

http://h30499.www3.hp.com/t5/ITRC-OV-ServiceCenter-Service/Any-way-to-add-a-record-to-activitycm3r-w...

hth
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Assign Kudo, if found post useful and mark it accepted if solves the issue.
http://h30499.www3.hp.com/t5/Tips-and-Tricks/Kudos-what-where-how-and-why/m-p/5677925#U5677925
Please use plain text.
Respected Contributor
Kelalek2
Posts: 180
Registered: ‎08-05-2011
Message 9 of 13 (726 Views)

Re: Negdatestamp in javascript to insert new activity

Bumping up an old thread, but seemingly nobody answered to this question...

 

I tried various ways, but finally this seems to work. 

 

phrase="'31/12/2199 18:00:00'-tod()"
subs.negdatestamp =system.functions.parse_evaluate(phrase,6);

 

So actually I'm using RAD application parse_evaluate to do the dirty job.

 

(RAD application sc.activity is were I found the "max value" for date, 31/12/2199 18:00:00.)

Please use plain text.
Regular Advisor
Blue_1
Posts: 161
Registered: ‎12-01-2010
Message 10 of 13 (715 Views)

Re: Negdatestamp in javascript to insert new activity

it didnt work in javascript. When i print phrase i get the value as NAN  (not a number)

Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,177
Registered: ‎07-21-2008
Message 11 of 13 (711 Views)

Re: Negdatestamp in javascript to insert new activity

Here's what we use -

 

var End = new Date('12/31/2199 11:00:00')

var Now = new Date(system.functions.tod())

var Duration = End-Now

var Duration = Duration/1000/60

var conDuration = new XMLDate(Duration)

conDuration= conDuration.getSCDateTimeString()

var Then = new Date(conDuration)

 

The end result is the variable 'Then' is the negative datestamp, so we have something like:

Activity.negdatestamp=Then

 

When creating an activity via javascript.

Please use plain text.
Regular Advisor
Blue_1
Posts: 161
Registered: ‎12-01-2010
Message 12 of 13 (709 Views)

Re: Negdatestamp in javascript to insert new activity

This is what i get when i print each line

 

 

Then                              Invalid Date
conDuration 2            67962 22:20:49
conDuration                [C++ object XMLDate] - P67962DT22H20M49S
Duration 2                   97866620.81668334
Duration                       5871997249001
Now                              Tue Dec 03 2013 12:39:10 GMT-0600 (CST)
End                                Tue Dec 31 2199 11:00:00 GMT-0600 (CST)

Please use plain text.
Honored Contributor
Jacob Heubner
Posts: 4,177
Registered: ‎07-21-2008
Message 13 of 13 (702 Views)

Re: Negdatestamp in javascript to insert new activity

Don't try to print it; use the code to generate the negdatestamp in your javascript activity record. The conDuration.getSCDateTimeString() function turns the conDuration value into a readable string the way you'd want the datestamp to look... But it's a string, so you can't set the value of the date field to the string. The new Date() function converts the data type from string to date so you can assign the value to the negdatestamp field within the activity record.

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation