How to read an attribute using JavaScript

ZB
Zdenek Bures
CESKA LEKARNA HOLDING, a.s.

Hello, is there a way to read values from Mobicontrol using JavaScript, please?

A user wants to somehow enter an IP address, which will be copied to xml file by JavaScript. The ways to enter it:

Example 1 - User creates a custom atrribute %NEW_IP% and fills it with IP 10.11.12.13
Example 2 - User creates a device name e.g. ABC_10.11.12.13
Example 3 - ... other ways?


Many Thanks
Regards

Zdenek

Edited 4 years ago
Android Scripting
ANSWERS
RC
Raymond Chan Diamond Contributor
4 years ago (edited 4 years ago)

Though I have filed feature request on custom-attribute support in the new javascript engine for over half a year,  I am not aware of any such implementatation in the latest device agent release.

ZB
Zdenek Bures
4 years ago (edited 4 years ago)

Thank you Raymond. I will contact support to find out if there is any progress. I consider it as a common behaviour.

RS
Rafael Schäfer
4 years ago

Hi Zdenek, why do you explicit want to use Javascript? 

And who is "the user" is it the admin user or phone user (i think you mean the phone user)?

1. You can create the custom attribute in the console in general, so no java script needed here

2. If "somehow the IP is entered and stored in an xml file" there's no java script in the console needed (don't know what you use for that)

3. The console reads the value from the xml by itself into the custom attributes if configured - no javascript needed

4. You can access the custom attribute (for your samples it will be possible) with the legacy scipting.

 
devrename "ABC_%MCCustomData:NEW_IP%"
ZB
Zdenek Bures
4 years ago

Hi, Rafael, let me explain.

A customer requests a bulk change of IP addresses via a script. He has Zebra devices that allow to create an xml file capable of setting the IP address on the device. He is able to run this xml via the mxconfig command.

Your Java Script has the ability to create such a file. I am looking for a source of IP addresses, such source should be custom attributes.

RS
Rafael Schäfer
4 years ago

So, if i now understood correctly:

You want a list of possible IP-addresses stored in custom attributes (centrally filled one time for all devices which is no problem but only one IP each or you have to work on a string (split etc.)) and then write that into an xml on the device and use one of that for the device as the new ip.

Is that correct understood?

ZB
Zdenek Bures
4 years ago (edited 4 years ago)

Hello Rafael,

yes, excactly, you are correct. And you are also correct that storing atrributes per device is not a problem.  The problem is to use stored IP and newly setup each device by a script. I cannot find any way, so I am trying to use the functionality of Zebra (StageNow, by using xml. This csp profile is called Wi-Fi Manager and can by applied by mxconfig command)

ZB
Zdenek Bures
4 years ago (edited 4 years ago)

Hello, for your information, reference number of this feature request is MC-134999.

RS
Rafael Schäfer
4 years ago

Wouldn't it be maybe the same (but not as comfortable) if you just would provide an xml file to the device (with file sync rule or via package) with this data in and this can be read via javascript i think. Or I'm wrong here now?

ZB
Zdenek Bures
4 years ago

Rafael, you're absolutely right. XML could be generated externally and uploaded using file synchronization for example. But the customer insists on the Mobicontrol scripting language. He knows that MobiControl has this potential and wants to use it. It is natural for JavaScript to work with variables, and a custom attribute is a variable.