HOW CAN I SET AND GET OPERATOR ID USING LOGIC?

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
SieAIP
Posts: 24
Joined: April 7th, 2020, 5:57 pm

HOW CAN I SET AND GET OPERATOR ID USING LOGIC?

Post by SieAIP »

hello CSPro Users community!
I wish to know how I can set up operator ID in my CSPro application and how to get back all IDs after running it.

From my research, the set and get operator id functions looks like these examples bellow;

1. SET OPERATOR ID FUNCTION

Code: Select all

	PROC USER_ID
	LF_USER_ID = USER_ID;
	if not loadcase(LOGINS_DICT,LF_USER_ID) then
		errmsg("Invalid login.");
		reenter;
	endif;
	setoperatorid(strip(LF_USER_NAME))
2. GET OPERATOR ID FUNCTION

Code: Select all

	// write out the operator ID for the PFF that we are going to
	// launch so that the interviewer does not have to enter it again
	filewrite(pffFile,"OperatorID=%s",getoperatorid());
I got the above examples from the CSPro user's guide version 7.2.1 (pages 412 and 388 respectively).

Please can someone tell me where I can set these in my application and make it work correctly?
I will also be happy if I can get some parameters explained in the logic above. Specifically I'm yet to understand what the following means:
i. LF_USER_ID = USER_ID;
ii. LOGINS_DICT,LF_USER_ID
iii. filewrite(pffFile,"OperatorID=%s",getoperatorid());

I look forward to receiving help pretty soon.
Thanks always guys!
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: HOW CAN I SET AND GET OPERATOR ID USING LOGIC?

Post by aaronw »

Have you set the operator ID?

In the designer (Options > Data Entry) there is an option to ask for the operator ID. Tic it and run your application. You'll be prompted to enter the operator id.
operator-id.PNG
operator-id.PNG (1.2 KiB) Viewed 3140 times

Alternatively, you can set it using using setoperatorid in logic. Any proc should work. I would recommend the first approach, if you just want the interviewer to enter their id.

The logic you're asking about was used to demonstrate a typical use for setoperatorid and getoperatorid.
  1. USER_ID currently holds the operator id an is assigning its value to LF_USER_ID
  2. LF_USER_ID now contains the operator id and is being used to load a case from LOGINS_DICT where the operator id exists
  3. The operator id is being written the the PFF from the menu application. This allows CSPro to pass information from one application to another. The intention is to have the interviewer enter their operator id in the menu, but not have to reenter it in the questionaire.
SieAIP
Posts: 24
Joined: April 7th, 2020, 5:57 pm

Re: HOW CAN I SET AND GET OPERATOR ID USING LOGIC?

Post by SieAIP »

I have used the first approach you recommend and it is working...

However, it is allowing any ID you type in, Names, numbers etc.

Now my issues are;
1. How can I make it such that only user names I want will be allowed access to the application?
2. How can I retrieve it? As in I want to get the operator IDs alongside the data each operator entered into the application... Probably the first column should return the operator IDs for all the cases...

What's the way forward please?
thanks! 👍
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: HOW CAN I SET AND GET OPERATOR ID USING LOGIC?

Post by aaronw »

If you want to restrict access you'll need to take a different approach. Take a look at the workshop materials. On page 66 it walks through the process of using a lookup file for login.

As an additional step add a staff code field to your questionnaire and pre-fill it after the interviewer has logged in. This is a straightforward way to link the questionnaire and interviewer together.
Post Reply