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

Thread: Test for field type in Javascript

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

    Default Test for field type in Javascript

    I have this function

    Code:
    function test(localrecord)
    {
      var output = new Array(0)
    	var map = new Array(0)
    	map.push("number")
    	map.push("brief.description")
    	map.push("update.action")
    
    	var count1 = map.length
    	for( var i = 0; i < count1; i++) 
    	{
    			output[i] = localrecord[map[i]]
    		
    	}
    }
    The array map contains a list of fields I want copied from localrecord to the array output. This function works fine for character fields but requires a bit more (it needs to be converted to a javascript array first) when it is array fields.

    So my question is how do I test the type so I can process the field properly?
    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
    Member
    Join Date
    Dec 2008
    Location
    Russia
    Posts
    72

    Default

    Hello,
    You can use system.functions.type(localrecord[map[i]])
    It returns the number which corresponds to certain variable type (I don't remember exactly this equivalence. I think you can find it in help).
    Best wishes, Pavel.

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

    Default

    Of course. I tried the javascript function typeof and that always returned object as type.

    Thanks it worked.
    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.

+ 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