Can @For and @While works on Web?

Dear all, Can @For be used on Web Application? I have tried but it seems like does not work. My formula is as below :

@For(n := 1;

n <= @Elements(AllStaff);

n := n + 1;

@SetField(“Leave”+@Text(n); AllStaff[n]);

xKey := @Text(@Year(@Today)) + Applicant+AllStaff[n];

Tkn_process :=@DbLookup(“”:“NoCache”; @DbName; “WLS”; xKey; “NoOfDay”);Tot :=@If(@IsError(@Sum(Tkn_process)); 0; @Sum(Tkn_process));

@SetField(“Day”+@Text(n); Tot))

Subject: Can @For and @While works on Web?

Yes it can, but it works in the same way as an @If or any other formula, so if you want to perform more than one function you need to nest the functions in an @Do statement,as below. Also it’s a good idea to use [FailSilent] for @DBLookups in ND6 so you don’t have to check for potential errors. Also, is the day field you’re trying to set a number field?

@For(n:= 1;n <= @Elements(AllStaff);n:= n + 1;

@Do(@SetField(“Leave” + @Text(n);AllStaff[n]);

xKey:=@Text(@Year(@Today)) + Applicant + AllStaff[n];

Tkn_process:=@DbLookup(“Notes”:“NoCache”; @DbName;“WLS”;xKey;“NoOfDay”;[FailSilent]);

Tot:=@If(@IsError(@Sum(Tkn_process));0;@Sum(Tkn_process));

@SetField(“Day” + @Text(n);Tot)))

Hope that works - it can be a bit fiddly sometimes…

Subject: RE: Can @For and @While works on Web?

Hi, Thanks for your reply.

 I have tried the formula, it still doesn't work. But it works fine on notes client. 

  I apply the formula in the button, and it is set to run on client using formula, will this affect the functionality on the web. We cannot set the button to run on web using formula in the button. Please give some advice.

  Thanks.

Subject: RE: Can @For and @While works on Web?

Sorry, I didn’t look closely enough - I think you’ll find the problem is with @SetField being present in the formula.

Whilst this works in the client, this probably won’t in the web because it would require the document to be refreshed to show the new field values.

I’d suggest you use JavaScript in the web to accomplish what you need to do.

Thanks,

Giles

Subject: Can @For and @While works on Web?

Short answer: Yes, @For works fine on the web.

Does your formula produce the correct result in the Notes client?