Unfortunately I can't make sense of your Employee Sync script. It changes layouts numerous times without any discernible reason (unless there are script triggers attached to those layouts).
However if I understand correctly that you want the Present/Absent/Half Day/Extra Day buttons (outside of the portal) to automatically update the status of all the people in the portal, you can use a Loop for that. So you could change your Attendance Type Present script to look more like this:
Go to Object [ Object Name: "LayAtt Portal" ]
Go to Portal Row [ Select: Off ; First ]
If [ IsEmpty ( AttendanceDetail::Status ) ]
Set Field [ AttendanceDetail::Status ; "Present" ]
Go to Portal Row [ Select: Off ; Next ; Exit after last ]
This will loop through all AttendanceDetail records in the portal and update their Status to "Present".
If your relationship to AttendanceDetail is set to allow creating new records, then the loop won't properly exit because it never reaches the "last" record (it continues creating new ones). So, if this is the case, add a line after the Loop that says Exit Loop If [ IsEmpty ( AttendanceDetail::AttDetID ) ]
A next step could then be to use one script for all the buttons (rather than a separate script for each button) where the buttons are configured to pass a specific parameter: "Present" or "Absent" or "Half Day" or "Extra Day" and then your script would have something like: Set Variable [ $Parameter ; Get ( ScriptParameter ) ] at the beginning, and then your Set Field script becomes: Set Field [ AttendanceDetail::Status ; $Parameter ]
Thanks Friend for your reply.Though Friend I am already using script for making employee wise attendance as per his day status in portal row from outside portal attendance type buttons and I getting the results also. Only the difference in script is which i have use without loop. Pls see in above pic No.1. Second you have said above that Unfortunately I can't make sense of your Employee Sync script. But that script is important for me to sync the each portal row employee details in all layout which are related (Employee Attendance Summary, Month details , Salary details and Employee details) with current Day Date and month respectively. And I am getting result what I want. My query is to only how to Add this (Emp Sync Button setup) script in (Attendance type Present) button setup scripts before go to Next portal row. As I have tried to add this before that but it does not go to next portal row after adding like this Pic.My motto for this is only I have to trigger one button of attendance type for each portal row to complete the cycle ( Attendance status as well as employee sync).At present I have to trigger both buttons ( Attendance type and employee sync) for each portal row.Thanks
Okay, the short answer is that the portal row is being reset to 1 in the Employee Sync script because you are changing layouts (and changing layouts implicitly commits the records which resets the portal row back to 1). A simple fix would be to add at the top of the Employee Sync script:
Set Variable [ $PortalRow ; Get ( ActivePortalRowNumber ) ]
Then, at the end of the script:
Go to Portal Row [ Select: Off ; By Calculation: $PortalRow ]
This resets the portal row back to where it was at the beginning of the script.
However, I strongly suggest you read through and learn from the following:
Let's look at the Employee Sync script:
Line 1 - Ok, it sets the variable $$MonthName to the month name.
Line 2 - This line seems unnecessary, unless there is an OnObjectEnter script trigger attached to the Employees_Attendance_AttendanceDetail::Emp... field. Is there a script trigger on that field? Otherwise, what do you think this step accomplishes?
Line 3 - The script goes to a related record, using the LayEmployees layout. Probably unnecessary (if you're going to a related record then you probably already have access to that record in the current layout and could change the field directly, albeit perhaps using a different table occurrence).
Line 4 - Saves the month name into some field. Okay, but why don't you set the field on the original layout using the TO used for the portal, rather than switching to a different layout?
Line 5 - This line is unnecessary, as you are already on the LayEmployees layout.
Line 6 - Performs some script
Line 7 - Goes to related records using the Salary Transactions Details layout. However, what is the purpose in going to this layout since in line 9 the script switches back to the original layout without having done anything here except to go to the first record (unless there is a script trigger involved)?
Line 8 - Goes to the first record (but doesn't do anything with that record, unless there is a script trigger involved)
Line 9 - Switches back to original layout
Line 10 - Goes to a Related Record using the LayMonths layout (but doesn't do anything on that layout). Is there a script trigger on the layout?
Line 11 - Switches back to the original layout
It seems to me that the script is designed base on a false assumption that fields only exist on a layout and so the script pretends to be a user, doing everything that a user would do (go to this layout, type in this field, go to this other layout, etc.). In actuality, fields exist in tables (referenced through table occurrences), and layouts only display the fields that they are configured to show. Layouts provide a context for table occurrences, but a script can directly access far beyond what is shown on the layout.
When writing a script it is best to think through what you want to accomplish with the data, not just trying to emulate what a user of the database would do.
I apologize that this is probably overwhelming. If you'd be willing to share your database, I'd be happy to look at it and modify the scripts so that perhaps you can see what I mean.
For now, I modified your script as follows.
Also, the "Sync Attandance Days No" script references an "EmployeeYear Salary Table" object that doesn't exist on the layout, but fortunately there is only one portal on the layout, so it doesn't cause a problem.
Unfortunately I don't have time right now to look more into it, but if I get a chance I'll try to look at it more thoroughly.
I got it what I assume. Covers all my needs. Once again I am very much thankful for your valuable tips.