14 Replies Latest reply on Dec 11, 2015 12:33 PM by BillisSaved

    Need help with a puzzling problem

    jdevans

      I may have designed myself into a corner on this, but I'll try as best I can to describe the problem.

       

      I have a list view layout based on a TO called Accounts. I'm using this Layout to allow users to enter time (in hours) for themselves in a time-card system at work.

      Each "row" on account records in this list view has 7 fields spread across from L to R, one for each day of the week. These fields are for entering in hour for any account the user spends time on. These are dumped into a second related table called Hours. It stores each Hours charge including the hours they worked, the account worked, the person who worked, and the date.

       

      I have a drop down menu at the top of the layout where the user can select their name from the list of employees, so they can enter time for themselves.

       

      The problem I'm facing is, I have button at the top of the layout for "approving and locking" the records, once the employee has determined that they are finished entering in their time for the week.

       

      1)  I want to only show this Approve/Lock button only to the person (via privilege set) who can do approvals, and

      2) I want to display replace that button with a do-nothing button/label that says "Approved" once it has been clicked.

      3) Also need the Approver person to be able to select each employee from the dropdown list, and approve for all employees who have completed their time for the week.

      4) I need the buttons to re-appear based on if an employee is selected from the dropdown who hasn't completed their time yet.

       

      I have a successful script that runs whens the Approve/Lock button is pressed. It loops thru the Hours records n a found set (this employee, this week), and sets two fields: 1) an "is_locked" to 1, and 2) "is_approved" to the user account and timestamp.

       

      I haven't been able to figure out a way to hid the Approve/Lock button and show the do-nothing button when conditions are right. Basically,I haven't figured out how to establish the conditions in the first place.

        • 1. Re: Need help with a puzzling problem
          Mike_Mitchell

          Using the Hide Object feature, you can have the two objects (the button and the "Approved" indicator) on top of each other, and use two calculations to hide them when appropriate. For the button:

           

               Case ( Get ( AccountPrivilegeSetName ) ≠ "yourPrivSetHere" )

           

          For the "Approved" indicator:

           

               Case ( IsEmpty ( is_approved ))

           

          HTH

           

          Mike

          • 2. Re: Need help with a puzzling problem
            jdevans

            Yes, I realize how to show/hide things like that, however multiple Accounts can be charged to during the same week. That doesn't work in this case/layout scenario.

            • 3. Re: Need help with a puzzling problem
              Mike_Mitchell

              jdevans wrote:

               

              Yes, I realize how to show/hide things like that, however multiple Accounts can be charged to during the same week. That doesn't work in this case/layout scenario.

               

               

              I'm not sure what that means, or why it matters. Can you provide more detail?

              • 4. Re: Need help with a puzzling problem
                BillisSaved

                Good afternoon jdevans,

                 

                I hope your day is going well. In criterion number three listed in your question, does selecting an employee name from the dropdown list add that employee's information to the displayed list (i.e. extend found set) or does the list show information for only the most recently selected employee? The way you've stated your goal it appears that the list expands to include the newly selected employee.

                • 5. Re: Need help with a puzzling problem
                  jdevans

                  timesheet_capture.PNG

                  On the included image, there are (visible) 4 individual time charges. M, T and W 8 hrs each  on the account called 4.1 CSP.  Friday, there is 8 hrs sick time. And not pictured in the capture, 8 hrs to a third account.

                  These constitute 5 separate records in the related table (Hours) of 8 hours each..  Yet, I'm looking at  a layout based on Accounts. This could be any number/combination of accounts depending on the week, and employee..

                   

                  I'm stuck on how to show or hide that Approved button based on the contents of a field among several records simultaneously.

                   

                  To make it more complicated, if the approver switches to a different employee, whose hours haven't been approved yet, I need to show that to him/her again, when a different employee is selected.

                  • 6. Re: Need help with a puzzling problem
                    jdevans

                    It switches to that employee's time-entries for that week, so that the previously selected employees records are no longer visible.. If I select a different week, the employee stays, and the week's time entries change. I have 7 separate query relationships (one for each day of the week) to handle separating out the time.

                    • 7. Re: Need help with a puzzling problem
                      jdevans

                      One thing I was hoping to use to try to solve this puzzle is that both the Account TO and the Hours TO have a calculated field that shows the week number. Notice on the top of the layout, (pictured) is the week number 45, of the week selected. This can be compared to the week number of each time-charge record in Hours. I can get a match on the two.

                      • 8. Re: Need help with a puzzling problem
                        BillisSaved

                        Hey jdevan,

                         

                        When the person who is authorized to approve the time entered on your layout clicks the "Approve" button, does it lock all of that week's records for the selected employee or only the entries with a time value entered? In other words, can an employee enter time values for Monday through Wednesday, have those approved, and then return to that week and enter entries for Thursday and Friday?

                        • 9. Re: Need help with a puzzling problem
                          jdevans

                          I was just wondering about that. I will have to test it. If I had to guess, I think it will set them as they exist.

                          • 10. Re: Need help with a puzzling problem
                            jdevans

                            Yes, it runs, even if the week is incomplete, approving the records that exist.

                             

                            I was thinking of checking for a complete week, but so many people have different work schedules, there are too many unknowns to check for that.

                            • 11. Re: Need help with a puzzling problem
                              jdevans

                              This may be more work that it's worth. I can restrict who uses the button. I can conditionally format the locked records. I can restrict editing records based on the is_locked condition in the privilege set. I may just leave it alone, and provide error handling with show custom dialog.

                              • 12. Re: Need help with a puzzling problem
                                BillisSaved

                                Hey jdevans,

                                 

                                Please keep in mind that I don't know your solution or applicable business rules as well as you do, however, assuming there is no great need to approve partial logged time, I think I would add a button to the layout, which the employee entering the time could use to indicate that all time has been entered, and then make the Approve button visibility dependent on that action...just a thought.

                                • 13. Re: Need help with a puzzling problem
                                  jdevans

                                  I like this. I think it will be easy to implement, and should provide adequate functionality.

                                  • 14. Re: Need help with a puzzling problem
                                    BillisSaved

                                    Hey jdevans,

                                     

                                    I use this method on occasion to facilitate automatic email notification messages; letting supervisors know when they need to address/approve something. Good luck!

                                     

                                    God bless,

                                    Bill