GetPrivateData Iteration

Post Reply
SunDev
Newbie
Posts: 4
Joined: Thu Mar 07, 2019 2:40 am

GetPrivateData Iteration

Post by SunDev »

I am trying to iterate through the collection/array and get the values that comes back from the getPrivateDataTags on the Job object using VbScript. I'm running into an issue. Whatever I do, I cannot iterate through the collection or get any values from the collection that comes back. I have tried multiple different methods to get the value from the returned array but no go. Any help here would be greatly appreciated.

datatags = job.getPrivateDataTags()
Call job.Log(MESSAGELEVEL_DEBUG, TypeName(datatags)) 'This works. String() is the response
Call job.Log(MESSAGELEVEL_DEBUG, Ubound(datatags)) 'This works. 6 is the response
Call job.Log(MESSAGELEVEL_DEBUG, CStr(datatags(1))) 'Doesn't work
for index = 0 to ubound(datatags)
Call job.Log(MESSAGELEVEL_DEBUG, CStr(datatags.Item(index))) 'Doesn't work
Next
SunDev
Newbie
Posts: 4
Joined: Thu Mar 07, 2019 2:40 am

Re: GetPrivateData Iteration

Post by SunDev »

In case other people have experienced this. After extensive digging I have found that the object returned from getPrivateDataTags cannot be read via vbscript.

Example:
datatags = job.getPrivateDataTags()
Call job.Log(MESSAGELEVEL_DEBUG, TypeName(datatags)) 'This works. String() is the response
Call job.Log(MESSAGELEVEL_DEBUG, Ubound(datatags)) 'This works. 6 is the response

If you run this VarType(datatags) it returns 8200.

Vbscript can't work with arrays that are not a variant array. The return of VarType(myarray) should be 8192 or 8204 otherwise Vbscript won't work. The object from above returns a strongly typed String(). So VbScript can't read the values although some methods will work on it (Example: UBound). This is probably true for other methods on the job and switch classes.
User avatar
gabrielp
Advanced member
Posts: 645
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Re: GetPrivateData Iteration

Post by gabrielp »

Thanks for following up with the solution! If it helps anyone else, here is a snippet of code I used previously to iterate over private data tags using JS: https://github.com/open-automation/swit ... js#L53-L65
Free Switch scripts: open-automation @ GitHub
Free Switch apps: open-automation @ Enfocus appstore

Want to hire me? I'm looking for my next gig. Contact me on LinkedIn or via email.
Post Reply