Page 1 of 1

GetDeviceID Function

Posted: June 22nd, 2020, 6:24 am
by SieAIP
Hello CSPro Users Forum!
can you guys please help me set up "GetDeviceID" function for my application? Here is my Application....
CAPI - Study Exercise.zip
(33.28 KiB) Downloaded 196 times
I have read about it in the CSPro manual and have even seen an example about it as below but I don't know where to set it up so I have attached my application here so that I can receive guide on it directly

Example

Code: Select all

PROC USER_NAME 
	if not loadcase(USER_PERMISSIONS_DICT,USER_NAME) then
		errmsg("The entered user name is not in the database of users.");
		reenter;
	elseif USER_ALLOWED_DEVICE <> getdeviceid() then
		errmsg("You, %s, do not have permission to use device %s.",strip(USER_NAME),getdeviceid());
		reenter;
	endif; 
Thank you all as I anticipate your help!

Re: GetDeviceID Function

Posted: June 22nd, 2020, 6:40 am
by josh
What exactly do you want to do with GetDeviceId?

Re: GetDeviceID Function

Posted: June 22nd, 2020, 12:04 pm
by SieAIP
I have about 10 devices and they are all syncing in the same place (location). I want to be able to trace the entries submitted from each device.

Re: GetDeviceID Function

Posted: June 22nd, 2020, 1:07 pm
by josh
The easiest way to do that is to add an alpha item to your dictionary to store the device id and assign it to the value of the GetDeviceID() function in your logic. No need to put the item on a form. Just add it to the dictionary and then somewhere in your logic add:

DEVICE_ID = GetDeviceId();

You could add that for example to the preproc of the questionnaire.

Re: GetDeviceID Function

Posted: June 22nd, 2020, 6:41 pm
by SieAIP
Please Josh I'm a statistician but not a good programmer...
I've attached an application to this post initially, can you guide me on how to assig the logic to the dictionary item using the attached application?
Or can you at least explain more from you previous response so that I can get it better?
Thanks!

Re: GetDeviceID Function

Posted: June 23rd, 2020, 6:28 am
by josh
Add an item to your dictionary named DEVICE_ID that is type alpha and length 36 (the device id is never more than 36 characters).

In the logic view click on STUDYEXERCISE_LEVEL in the tree on the left to show the PROC STUDYEXERCISE_LEVEL and then add the following to that proc:

Code: Select all

preproc
DEVICE_ID = GetDeviceId();
That logic will run when you start a questionnaire and it will save the the device id to the variable you added to the dictionary.

Re: GetDeviceID Function

Posted: June 23rd, 2020, 9:58 am
by SieAIP
Thanks loads Josh! I'm on track now.
I do not take your help for granted, I'm grateful...

Re: GetDeviceID Function

Posted: June 23rd, 2020, 11:27 am
by khurshid.arshad
Please keep in your mind that if enumerator or anyone do the factory reset, the tablet at any stage the Deveice ID will be changed.

a.

Re: GetDeviceID Function

Posted: June 24th, 2020, 4:49 am
by SieAIP
Ok, taken, thanks!