Timecard Use Case

  • 2
  • Question
  • Updated 2 years ago
  • In Progress
I'm making a skuid page for a simple timecard use case. The top of the page has 2 buttons: clock-in and clock-out, both of which should be set to NOW. The bottom of the page simply displays a table of the data. Questions:

1) For the clock-out, I can't figure out how to query my model to give me the row of data from today that does not yet have a clock-out value and insert NOW. Doesn't seem to hard in theory, but I am new to skuid. I've disabled the clock-in button so it can only be used once per day.

2) I'd like to use a UI field to calculate the total time worked...can that be done with timedate fields?

Photo of Erica Wheeler

Erica Wheeler

  • 106 Points 100 badge 2x thumb

Posted 2 years ago

  • 2
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Erica,

1) Set your Clock-Out button to run multiple actions.  Add a model on your timesheet object that returns one row.  Set the conditions to return records for the current user and where the Time Out field is blank/none.  On your button you will Query the new model, update the Time Out field with now, save the new model, and then query your timesheet model.

2) Here is what the formula looks like to calculate the number of Hours:

IF(ISBLANK({{TimeOut}}),null,({{TimeOut}} - {{TimeIn}})/1000/60/60)

I have attached a sample page based on the Task object to demonstrate the solution.

Thanks,

Bill

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Task">    <models>
        <model id="Task" limit="100" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Task" type="" orderby="CreatedDate DESC">
            <fields>
                <field id="Subject"/>
                <field id="CreatedDate"/>
                <field id="ActivityDate"/>
                <field id="ReminderDateTime"/>
                <field id="Duration" uionly="true" displaytype="FORMULA" label="Duration (Hrs)" ogdisplaytype="TEXT" readonly="true" returntype="DOUBLE" precision="9" scale="2">
                    <formula>IF(ISBLANK({{ReminderDateTime}}),null,({{ReminderDateTime}} - {{CreatedDate}})/1000/60/60)</formula>
                </field>
            </fields>
            <conditions>
                <condition type="userinfo" value="" field="OwnerId" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
            </conditions>
            <actions/>
        </model>
        <model id="RecentTask" limit="1" query="false" createrowifnonefound="false" datasource="salesforce" sobject="Task" type="" orderby="CreatedDate DESC">
            <fields>
                <field id="Subject"/>
                <field id="CreatedDate"/>
                <field id="ActivityDate"/>
                <field id="ReminderDateTime"/>
            </fields>
            <conditions>
                <condition type="userinfo" value="" field="OwnerId" operator="=" enclosevalueinquotes="true" userinfotype="userid"/>
                <condition type="blank" value="null" field="ReminderDateTime" operator="=" enclosevalueinquotes="false"/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <pagetitle model="Task" uniqueid="sk-2gBr9v-93">
            <maintitle>
                <template>{{Model.labelPlural}}</template>
            </maintitle>
            <subtitle>
                <template>Home</template>
            </subtitle>
            <actions>
                <action type="multi" label="Set Reminder Date" icon="fa-clock-o">
                    <actions>
                        <action type="requeryModel" model="RecentTask" behavior="standard"/>
                        <action type="updateRow" fieldmodel="RecentTask" affectedrows="context" field="ReminderDateTime" enclosevalueinquotes="false" value="NOW"/>
                        <action type="save">
                            <models>
                                <model>RecentTask</model>
                            </models>
                        </action>
                        <action type="requeryModel" model="Task" behavior="standard"/>
                    </actions>
                </action>
                <action type="savecancel">
                    <savehotkeys>
                        <hotkey modifiers="ctrl" key="s"/>
                    </savehotkeys>
                </action>
            </actions>
        </pagetitle>
        <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Task" mode="read" allowcolumnreordering="true" uniqueid="sk-2gBr9v-94">
            <fields>
                <field id="Subject" hideable="true" allowordering="true" uniqueid="fi-2gBqC0-373" valuehalign="" type=""/>
                <field id="CreatedDate" hideable="true" allowordering="true" uniqueid="fi-2gBqC0-374" valuehalign="" type=""/>
                <field id="ReminderDateTime" hideable="true" uniqueid="fi-2gC6EW-152" valuehalign="" type="" allowordering="true"/>
                <field id="Duration" hideable="true" uniqueid="fi-2gCUUH-276" decimalplaces="" valuehalign="" type=""/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
    </components>
    <resources>
        <labels/>
        <css/>
        <javascript/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>