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

Thread: Getnumb from javascript

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

    Default Getnumb from javascript

    Some rtecalls work in javascript others dont. A rather important rtecall "getnumb" does not work so I had to find a way to get a unique number from the number file så I wrote this script.


    Code:
    function GetNextNumber(numberclass)
    {
     var recNumber = new SCFile("number");
     var rc;
     strSql = "name=\"eventin\""
     if (recNumber.doSelect( strSql ) == RC_SUCCESS )
     {
      var intNumber = recNumber.number;
      recNumber.number++;
      rc = recNumber.doAction("save");
      if ( rc != RC_SUCCESS)
      {
       do
       {
        if (recNumber.doSelect( strSql ) == RC_SUCCESS )
        {
         intNumber = recNumber.number;
         recNumber.number++;
         rc = recNumber.doAction("save");
        }
       }
       while (rc != RC_SUCCESS)
      }
     }
     return String(intNumber);
    }
    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.

  2. #2
    Junior Member
    Join Date
    Jul 2008
    Posts
    18

    Default

    Thanks, Tommy.

  3. #3
    Senior Member
    Join Date
    Apr 2007
    Posts
    160

    Default Thanks

    Nice one Tommy.

    Martin

  4. #4
    Senior Member mateuszk's Avatar
    Join Date
    Nov 2006
    Posts
    302

    Default

    Quote Originally Posted by tommy View Post
    Some rtecalls work in javascript others dont.
    Not to be picky or anything but, in this case this is not true.

    Code:
    var numbVal = new SCDatum();
    var rc=system.functions.rtecall("getnumber", retCode, numbVal, "numberclass");
    This rtecall does not return the val. of new number but sets a specified variable to this value.

    Other than that, you're right.
    Some rtecalls are just too complicated to use in JS
    and might be considered non-working

  5. #5
    Senior Member
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    291

    Default

    I have a different approach.... I create an action in default state of DEFAULT Object. This action calls a Process with rtecall("getnumber"...). The returned number (variable) I use in JavaScript code.....

    Greetings,

    Lars

  6. #6
    Senior Member
    Join Date
    Apr 2009
    Location
    Sydney, Australia
    Posts
    104

    Default

    Hmmm.....Its working in mine. Or maybe I just misunderstood your problem, I apologize for that. As an additional information, here's what I did:

    I am using SM 7.10

    I created a file import descriptor that uses a format control.

    I need to upload a csv file to the device table. Unfortunately, the field that I need to upload data to is an array of structure. You can't see those fields when you're using the file import wizard.

    So, what I did was to use a staging table and attached a format control on that staging table.

    I am using the following in the format control to generate the asset ID:

    var callRtn = new SCDatum;
    var nextNumber = new SCDatum;
    system.functions.rtecall("getnumber", callRtn, nextNumber, "device");
    vars.$G_asset_id = nextNumber.getText();

    Then I assign the vars.$G_asset_id to the id field of device and its working. I was able to upload the contents of the csv file and it created a CI record and populated the field with an array of structure type.

+ 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