Can I rename Device Name with Custom Data

Solved
R
rathasatekun
Gosoft (Thailand) Co.,Ltd.

I have Custom Data  and i want to set into device name , Can I?

a year ago
Android
ANSWERS

Of course via legacy script:

devrename "%MCCustomData:NameOfYourData%"
 
Just for your information: Javascript is not possible but we are waiting for the next Javascript releases to make custom data available directly (Zafer showed up below the indirect way which is possible right now already) there as well (currently only custom attribute supported).
ZC
Zafer Cigdem
a year ago

Hi,

Above legacy script worked well. In addition to;

I'm using JS method as well. It's working well on my environment, please see the syntax as following:

mobicontrol.device.renameTo("New name via JS ");
 
 
 
Zafer

But you can't use custom data there just a predefined string which is not what he has requested @Zafer. Especially if the user needs to enter something on the device to define naming and maybe relocation as well.

ZC
Zafer Cigdem
a year ago

Hi @Rafael,

Thank you for your reply. I think, I get the request. Custom data works reading a file from the device, so what we can do:

- We can read the file directly from the device by using a JS, so this way we can know what is the value of the custom data

- And then we can use this data as a variable and change the device name. Example as following to read value from the .ini file from the device to device it's custom data value. 

var count = new mobicontrol.io.File('/sdcard/Download/user_name.ini');

var text_read = count.readText();

mobicontrol.log.info('Read info is:' +text_read);

I've done some automation process by using a similar method earlier. If this does not makes sense please let me know

Zafer

Solution
ZC
Zafer Cigdem
a year ago

To verify it's working by using a variable it can be quickly tested only using below as well:

var new_name = "new name";
mobicontrol.device.renameTo(new_name);
 

Ok, thats true you can pick the data from the ini or xml file directly.
To be honest haven't had that in mind before, sorry for that.

Doing it that way i need to agree you can do it using JS as well ;)