couldn't make an automatically end-time in survey

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
lusia
Posts: 49
Joined: March 28th, 2018, 4:56 am

couldn't make an automatically end-time in survey

Post by lusia »

Dear all,
I have a problem when I make an automatically end-time for more than once visitation in a survey.
When the application ended on a partial save, the end-time will be filled in automatically.
And I wrote the script in each item as I don't know in which item the user will use partial save function.
Here is my script for automatically end-time in a partial save mode:

Code: Select all

if ispartial() = 1 then
	if END_TIME_1 = notappl then
		END_TIME_1 = systime("HH");
		END_MINUTE_1 = systime("MM");
	elseif END_TIME_1 <> notappl and END_TIME_2 = notappl then
		END_TIME_2 = systime("HH");
		END_MINUTE_2 = systime("MM");
	elseif END_TIME_1 <> notappl and END_TIME_2 <> notappl and END_TIME_3 = notappl then
		END_TIME_3 = systime("HH");
		END_MINUTE_3 = systime("MM");
	endif;		
endif;
It worked only on END_TIME_1 and END_MINUTE_1 items.
The rest is blank.

Kindly please help me.
Thank you in advance.

Regards,
lusia
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: couldn't make an automatically end-time in survey

Post by josh »

Are you using system controleld mode and are the variables for end time on a form after the field where the partial save is taking place? If so then they will be off path and the value would be notappl. You would need to use visualvalue() to read them.

Also ispartial() does not tell you if the case is in the process of being partially saved. It tells if you the case was partially saved last time. I think you what you want to do is to add a custom onstop function (http://www.csprousers.org/help/CSPro/on ... ction.html) and add set the end time in that function.
lusia
Posts: 49
Joined: March 28th, 2018, 4:56 am

Re: couldn't make an automatically end-time in survey

Post by lusia »

I'm using operator controlled mode in my apps. I've added visualvalue() in there.
Here is my new script:

Code: Select all

function OnStop()
	savepartial();
	if visualvalue(END_HOUR_1) = notappl then
		END_HOUR_1 = systime("HH");
		END_MINUTE_1 = systime("MM");
	elseif visualvalue(END_HOUR_1) <> notappl and visualvalue(END_HOUR_2) = notappl then
		END_HOUR_2 = systime("HH");
		END_MINUTE_2 = systime("MM");
	elseif visualvalue(END_HOUR_1) <> notappl and visualvalue(END_HOUR_2) <> notappl and visualvalue(END_HOUR_3) = notappl then
		END_HOUR_3 = systime("HH");
		END_MINUTE_3 = systime("MM");
	endif;
	stop(1);
end;
It didn't worked. It shows a blank record in my end-time item when I checked it out via export data to .csv.

Because we don't know where the user will use savepartial(), so I used the script without last_field description.
I'm still trying to get the right answer.
But again, kindly please help me.

Is there any suggestion?

Regards,
lusia
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: couldn't make an automatically end-time in survey

Post by josh »

If you are using operator controlled mode then visualvalue is not the problem. In operator controlled mode you always get the visualvalue.

Try moving the savepartial() just before the stop(1). They way your logic is now you are doing the save BEFORE you set the endtime so the endtime does not get saved.
lusia
Posts: 49
Joined: March 28th, 2018, 4:56 am

Re: couldn't make an automatically end-time in survey

Post by lusia »

I've moved the savepartial() just before stop().

Code: Select all

function OnStop()
	if END_HOUR_1 = notappl then
		END_HOUR_1 = systime("HH");
		END_MINUTE_1 = systime("MM");
	elseif END_HOUR_1 <> notappl and END_HOUR_2 = notappl then
		END_HOUR_2 = systime("HH");
		END_MINUTE_2 = systime("MM");
	elseif END_HOUR_1 <> notappl and END_HOUR_2 <> notappl and END_HOUR_3 = notappl then
		END_HOUR_3 = systime("HH");
		END_MINUTE_3 = systime("MM");
	endif;
	savepartial();
	stop(1);
end;
It works, Josh.
Thank you very much for the help. :D :D :D

Regards,
lusia
Post Reply