Weekly View in Timesheet Submission

From 3B Knowledge
Jump to navigation Jump to search

Version 2.3 of WFM adds a new Weekly View to the Timesheet Submission app. Please find below a sample schema for an OOTB implementation.

Properties

The important new fields are:

  • Now shift and request schedulable has 2 sets of fields that are required:
    • "startFieldPath":"b3s__Absolute_Start_Time__c",
    • "endFieldPath":"b3s__Absolute_End_Time__c",
    • "actualStartFieldPath":"b3s__Actual_Start_Time__c",
    • "actualEndFieldPath":"b3s__Actual_End_Time__c",
  • submitForApprovalLabel - (available on the shift and expense schedulable) this property overrides the label of the button for approval
  • weeklyViewTitle - this array allows you to define the fields to be displayed on the left hand side for each row added in weekly view. Note, these fields are usually in line with the weeklyViewRowFields, as we are not creating a DB record by creating a new row, so the field values need to be user provided
  • weeklyViewRowFields - an array of fields that will form a "key" i.e. Job - Site - Placement is a good example for a key. When a user creates a combination of these fields, a new row is displayed

Version 2.6 Changes

From version 2.6+, there is a new property on the shift schedulable "weeklyViewRecordFields" which allows you to

"weeklyViewRecordFields": [
 	{
       "field":"b3s__Comments__c",
       "type":"field-text-area",
       "required":false,
       "disabled":false
    }
 ],

Note: If you define a field in the weeklyViewRecordFields (which will be editable per shift) and the same field is defined in the weeklyViewRowFields, then the weeklyViewRowFields will be auto-applied to the shift and if the user edits the shift, the weeklyViewRecordFields field will win and overwrite the default value from the weeklyViewRowFields.

Sample full schema

{
   "timezonePreference": "user",
      "schedulables":{
      "shift":{
         "objectType":"b3s__Shift__c",
         "startFieldPath":"b3s__Absolute_Start_Time__c",
         "endFieldPath":"b3s__Absolute_End_Time__c",
         "actualStartFieldPath":"b3s__Actual_Start_Time__c",
         "actualEndFieldPath":"b3s__Actual_End_Time__c",
         "selectionClause":[
            "b3s__Contact__c = :contactUserId AND b3s__Contact__c != null"
         ],
         "totalHoursFieldPath":"b3s__Absolute_Length__c",
         "title":[
            {
               "label":"Scheduled Start",
               "fieldPath":"b3s__Scheduled_Start_Time__c",
               "formatter":"dateTime",
               "hideIfNull":true
            },
            {
               "label":"Scheduled End",
               "fieldPath":"b3s__Scheduled_End_Time__c",
               "formatter":"dateTime",
               "hideIfNull":true
            },
            {
               "label":"Actual Start",
               "fieldPath":"b3s__Actual_Start_Time__c",
               "formatter":"dateTime",
               "hideIfNull":true
            },
            {
               "label":"Actual End",
               "fieldPath":"b3s__Actual_End_Time__c",
               "formatter":"dateTime",
               "hideIfNull":true
            },
            {
               "label":"Contact",
               "fieldPath":"b3s__Contact__r.Name",
               "hideIfNull":false
            },
            {
               "label":"Job",
               "fieldPath":"b3s__Job__r.Name",
               "hideIfNull":false
            },
            {
               "label":"Site",
               "fieldPath":"b3s__Site__r.Name",
               "hideIfNull":false
            },
            {
               "label":"Comments",
               "fieldPath":"b3s__Comments__c",
               "hideIfNull":false
            },
            {
               "label":"Length",
               "fieldPath":"b3s__Absolute_Length__c",
               "hideIfNull":false
            },
            {
               "label":"Approval Status",
               "fieldPath":"b3s__Approval_Status__c",
               "hideIfNull":false
            }       
         ],
         "canEdit":{
            "condition":{
               "allOrSome":"all",
               "selectors":[
                  {
                     "field":"b3s__Approval_Status__c",
                     "operator":"isnull",
                     "value":true
                  }
               ]
            }
         },
         "canDelete":{
            "condition":{
               "allOrSome":"all",
               "selectors":[
                  {
                     "field":"b3s__Approval_Status__c",
                     "operator":"isnull",
                     "value":true
                  }
               ]
            }
         },
         "isSubmitted": {
            "condition":{
               "allOrSome":"all",
               "selectors":[
                  {
                     "field":"b3s__Approval_Status__c",
                     "operator":"equals",
                     "value": "Submitted"
                  }
               ]
            }
         },
         "submissionFormFields":[
            {
               "field":"b3s__Approval_Status__c",
               "type":"field-select",
               "required":true,
               "disabled":true,
               "default":"Submitted"
            }
         ],
         "submitForApprovalLabel": "Submit Shifts 2",
         "weeklyViewTitle":[
            {
               "label":"Contact",
               "fieldPath":"b3s__Contact__r.Name",
               "hideIfNull":false
            },
            {
               "label":"Job",
               "fieldPath":"b3s__Job__r.Name",
               "hideIfNull":false
            },
            {
               "label":"Site",
               "fieldPath":"b3s__Site__r.Name",
               "hideIfNull":false
            },
            {
               "label":"Placement",
               "fieldPath":"b3s__Placement__r.Name",
               "hideIfNull":false
            }
         ],
         "weeklyViewRowFields": [
            {
               "field":"b3s__Contact__c",
               "type":"field-select",
               "required":false,
               "disabled":true,
               "default":":contactUserId",
               "loader":"contacts",
               "optionLabelField":"Name"
            },
            {
               "field":"b3s__Job__c",
               "labelOverride":"Job",
               "type":"field-select",
               "required":true,
               "disabled":false,
               "default":":contactUserId",
               "optionsInPopout":true,
               "loader":"jobs",
               "optionLabelField":"Name"
            },
            {
               "field":"b3s__Site__c",
               "type":"field-select",
               "required":false,
               "disabled":false,
               "optionsInPopout":true,
               "loader":"sites",
               "optionLabelField":"Name"
            },
            {
               "field":"b3s__Placement__c",
               "labelOverride":"Placement",
               "type":"field-select",
               "required":false,
               "disabled":{
                  "condition":{
                     "allOrSome":"all",
                     "selectors":[
                        {
                           "field":"b3s__Contact__c",
                           "operator":"isnull",
                           "value":true
                        }
                     ]
                  }
               },
               "optionsInPopout":true,
               "loader":"placements",
               "optionLabelField":"Name",
               "optionExtendedDetails":[
                  {
                     "label":"Person Placed",
                     "targetField":"b3o__Candidate__r.Name"
                  }
               ],
               "showOptionIf":{
                  "condition":{
                     "allOrSome":"all",
                     "selectors":[
                        {
                           "field":"b3s__Contact__c",
                           "operator":"equals",
                           "targetField":"b3o__Candidate__c"
                        },
                        {
                           "field":"b3s__Job__c",
                           "operator":"equals",
                           "targetField":"b3o__Job__c"
                        }
                     ]
                  }
               }
            }
         ],
         //Available after version 2.6
         "weeklyViewRecordFields": [
         	{
               "field":"b3s__Comments__c",
               "type":"field-text-area",
               "required":false,
               "disabled":false
            }
         ],
         "recordFormFields":[
            {
               "isSeparator":true,
               "label":"Times"
            },
            {
               "field":"b3s__Scheduled_Start_Time__c:b3s__Scheduled_End_Time__c",
               "labelOverride":"Scheduled Times",
               "type":"field-time-range-selector",
               "required":false,
               "disabled":true
            },
            {
               "field":"b3s__Actual_Start_Time__c:b3s__Actual_End_Time__c",
               "props":{
                  "hideDate":true,
                  "totalHoursOnly":true

               },
               "labelOverride":"Actual Times",
               "type":"field-time-range-selector",
               "required":true,
               "disabled":false
            },
            {
               "isSeparator":true,
               "label":"Details"
            },
            {
               "field":"b3s__Contact__c",
               "type":"field-select",
               "required":false,
               "disabled":true,
               "default":":contactUserId",
               "loader":"contacts",
               "optionLabelField":"Name"
            },
            {
               "field":"b3s__Job__c",
               "labelOverride":"Job",
               "type":"field-select",
               "required":true,
               "disabled":false,
               "default":":contactUserId",
               "optionsInPopout":true,
               "loader":"jobs",
               "optionLabelField":"Name"
            },
            {
               "field":"b3s__Site__c",
               "type":"field-select",
               "required":false,
               "disabled":false,
               "optionsInPopout":true,
               "loader":"sites",
               "optionLabelField":"Name"
            },
            {
               "field":"b3s__Placement__c",
               "labelOverride":"Placement",
               "type":"field-select",
               "required":false,
               "disabled":{
                  "condition":{
                     "allOrSome":"all",
                     "selectors":[
                        {
                           "field":"b3s__Contact__c",
                           "operator":"isnull",
                           "value":true
                        }
                     ]
                  }
               },
               "optionsInPopout":true,
               "loader":"placements",
               "optionLabelField":"Name",
               "optionExtendedDetails":[
                  {
                     "label":"Person Placed",
                     "targetField":"b3o__Candidate__r.Name"
                  }
               ],
               "showOptionIf":{
                  "condition":{
                     "allOrSome":"all",
                     "selectors":[
                        {
                           "field":"b3s__Contact__c",
                           "operator":"equals",
                           "targetField":"b3o__Candidate__c"
                        },
                        {
                           "field":"b3s__Job__c",
                           "operator":"equals",
                           "targetField":"b3o__Job__c"
                        }
                     ]
                  }
               }
            },
            {
               "field":"b3s__Comments__c",
               "type":"field-text-area",
               "required":false,
               "disabled":false
            },
            {
               "field":"",
               "labelOverride": "Upload",
               "type":"field-file-upload",
               "props": {
                    "placeholder": "Upload File",
                    "maxFileSize": 1000000
                },

               "required":false,
               "disabled":false
            }
         ],
         "decorations":[
            {
               "name":"shift-clocked-in",
               "condition":{
                  "allOrSome":"all",
                  "selectors":[
                     {
                        "field":"b3s__Actual_Start_Time__c",
                        "operator":"isnull",
                        "value":false
                     }
                  ]
               },
               "icon":{
                  "svg":"<svg  xmlns='http://www.w3.org/2000/svg'  width='24'  height='24'  viewBox='0 0 24 24'  fill='none'  stroke='currentColor'  stroke-width='2'  stroke-linecap='round'  stroke-linejoin='round'  class='icon icon-tabler icons-tabler-outline icon-tabler-clock'><path stroke='none' d='M0 0h24v24H0z' fill='none'/><path d='M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0' /><path d='M12 7v5l3 3' /></svg>"
               },
               "title":{
                  "literal":"Has Start Time"
               }
            }
         ]
      },
      "expense":{
         "objectType":"b3s__Expense__c",
         "startFieldPath":"b3s__Expense_Date_Query__c",
         "endFieldPath":"b3s__Expense_Date_Query__c",
         "selectionClause":[
            "b3s__Contact__c = :contactUserId AND b3s__Contact__c != null"
         ],
         "title":[
            {
               "label":"Date",
               "fieldPath":"b3s__Date_of_Expense__c",
               "formatter":"date",
               "hideIfNull":false
            },
            {
               "label":"Category",
               "fieldPath":"b3s__Category__c",
               "hideIfNull":false
            },
            {
               "label":"Comments",
               "fieldPath":"b3s__Submitter_Comments__c",
               "hideIfNull":true
            },
            {
               "label":"Total Value",
               "fieldPath":"b3s__Total_Value__c",
               "hideIfNull":false
            },
            {
               "label":"Approval",
               "fieldPath":"b3s__Approval_Status__c",
               "hideIfNull":true
            }
         ],
         "canEdit":{
            "condition":{
               "allOrSome":"all",
               "selectors":[
                  {
                     "field":"b3s__Approval_Status__c",
                     "operator":"isnull",
                     "value":true
                  }
               ]
            }
         },
         "canDelete":{
            "condition":{
               "allOrSome":"all",
               "selectors":[
                  {
                     "field":"b3s__Approval_Status__c",
                     "operator":"isnull",
                     "value":true
                  }
               ]
            }
         },
         "isSubmitted": {
            "condition":{
               "allOrSome":"all",
               "selectors":[
                  {
                     "field":"b3s__Approval_Status__c",
                     "operator":"equals",
                     "value": "Submitted"
                  }
               ]
            }
         },
         "submissionFormFields":[
            {
               "field":"b3s__Approval_Status__c",
               "type":"field-select",
               "required":true,
               "disabled":true,
               "default":"Submitted"
            }
         ],
         "submitForApprovalLabel": "Submit Expenses 2",
         "recordFormFields":[
            {
               "isSeparator":true,
               "label":"Times"
            },
            {
               "field":"b3s__Date_of_Expense__c",
               "props":{
                  "hideDate":true
               },
               "labelOverride":"Date of Expense",
               "type":"field-date-input",
               "default":":contextDate",
               "required":true,
               "disabled":false
            },
            {
               "isSeparator":true,
               "label":"Details"
            },
            {
               "field":"b3s__Contact__c",
               "type":"field-select",
               "required":false,
               "disabled":true,
               "default":":contactUserId",
               "loader":"contacts",
               "optionLabelField":"Name"
            },
            {
               "field":"b3s__Category__c",
               "type":"field-select",
               "optionsInPopout":true,
               "default":"Meals",
               "required":false,
               "disabled":false
            },
            {
               "field":"b3s__Currency__c",
               "type":"field-select",
               "optionsInPopout":true,
               "default":"USD",
               "required":true,
               "disabled":false
            },
            {
               "field":"b3s__Total_Value__c",
               "type":"field-number-input",
               "required":true,
               "disabled":false
            },
            {
               "field":"b3s__Submitter_Comments__c",
               "type":"field-text-area",
               "required":false,
               "disabled":false
            },
            {
               "field":"",
               "labelOverride": "Upload",
               "type":"field-file-upload",
               "props": {
                    "placeholder": "Upload File",
                    "maxFileSize": 1000000
                },

               "required":false,
               "disabled":false
            }
         ]
      }
   }
}