Want to get rid of Google Ads, click here.
+ Reply to Thread
Results 1 to 9 of 9

Thread: JavaScript Trigger

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    17

    Default JavaScript Trigger

    I created a trigger on table activityservicemgt

    Trigger code:

    var NewRecord=system.vars.$L_new;

    print(" wpis : "+ NewRecord);

    var opis = NewRecord.description;

    print("desc "+ opis );



    Trigger is After update. And I get a error when I add new activitis:

    Interaction SD12 has been updated. (info)
    wpis : null (info)
    Script <no name> line 6: ERROR TypeError: NewRecord has no properties at char 1 (error)

    I try to change system.vars.$L_new variable to $L_file , $L_old but it don`t work.

    Can someone any idea?
    I use HP SM 7.00.010

  2. #2
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,271

    Default

    First I suggest you move your code to a javascript library. It is easier to test it there.

    Then you call it like this in the trigger:

    system.library.SCRIPTLIBRARY.FUNCTIONAME(vars.$L_f ile)

    The function could then look like this:

    function functioname(localRecord)
    {
    var opis = localRecord.description;
    print("desc "+opis);

    }
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  3. #3
    Junior Member
    Join Date
    Feb 2008
    Posts
    17

    Default

    Thanks a lot, You save me a lof of time.

    I used

    system.library.bccTestScript.BCCTEST1(system.funct ions.filename(record),record);

    i now it work fine

    I had one more question, can I execute event from java script?
    I want to do a automatic creation of an incident from a new interaction. I know that epmosmu event do it.

    Thx
    Last edited by meton00; 2008-03-13 at 14:34.

  4. #4
    Senior Member glg's Avatar
    Join Date
    Aug 2004
    Location
    Chicago, IL, USA
    Posts
    714

    Default

    The key is to use record instead of $L.new and oldrecord instead of $L.old in the trigger javascript.

  5. #5
    Junior Member
    Join Date
    Jan 2008
    Posts
    3

    Default

    I have the same problem. How to execute event from java script?

  6. #6
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,271

    Default

    You need to build the event and add it to eventin table. Then it will be executed by the backgroung process event.
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  7. #7
    Junior Member
    Join Date
    Feb 2008
    Posts
    17

    Default

    Hello
    I have used Your suggestion and it work but with one surprising error. When I create a interaction system loss the $lo.user.name variable. He see it when I use RAD debugger but when I write a activity note (In any other incident/inderaction) he add it without the operator name.
    2008/03/27 16:06:46 Europe/Middle (NULL):
    TEST
    After a logout it is ok.
    Trigger code :

    var eventInList =new SCFile ("eventin");

    eventInList.evtype ="epmosmu";
    eventInList.evstatus ="Opened Related";
    eventInList.evtimestamp =newDate();

    eventInList.evsysseq =record.incident_id;
    eventInList.evsepchar ="^";
    eventInList.evfields =record.incident_id +"^"+record.description.toArray() +"^external";
    var a =eventInList.doInsert();

    I don`t know how to generate the next sequence key so I used interaction ID.
    Any idea how to deal with this?

  8. #8
    Senior Member glg's Avatar
    Join Date
    Aug 2004
    Location
    Chicago, IL, USA
    Posts
    714

    Default

    try setting evuser in the event.

  9. #9
    Junior Member
    Join Date
    Feb 2008
    Posts
    17

    Default

    I have tried but the result are the same.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts