List index out of bounds: 1 Overriding DateTime Field

I am getting a List index out of bounds: 1 error while using the update field when row is updated action. I am trying to update the EndDateTime field with the StartDateTime field’s value any time the StartDateTime is changed. These fields are both being overriden to convert from DateTime to Date fields. 

Help, please? :) 

Josef,

I have this working in Skuid 10.0.x. I think you are on the same version.

The way I made it work ‘declaratively’ is to edit the XML and replace the ‘value’ with the merge syntax for {{StartDateTime}}.

                    <action type="updateRow" model="Event" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context" fieldmodel="Event" field="EndDateTime" enclosevalueinquotes="false" value="<b>{{StartDateTime}}</b>"/>

Here is my XML:

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Event">
    <models>
        <model id="Event" limit="1" query="false" createrowifnonefound="true" datasource="salesforce" sobject="Event" type="">
            <fields>
                <field id="Subject"/>
                <field id="EndDateTime"/>
                <field id="StartDateTime"/>
            </fields>
            <conditions/>
            <actions>
                <action>
                    <actions>
                        <action type="updateRow" model="Event" appendorprepend="prepend" defaultmodefornewitems="edit" affectedrows="context" fieldmodel="Event" field="EndDateTime" enclosevalueinquotes="false" value="{{StartDateTime}}"/>
                    </actions>
                    <events>
                        <event>row.updated</event>
                    </events>
                    <fields>
                        <field>StartDateTime</field>
                    </fields>
                </action>
            </actions>
        </model>
    </models>
    <components>
        <pagetitle model="Event" uniqueid="sk-uji7t-91">
            <maintitle>
                <template>New {{Model.label}}</template>
            </maintitle>
            <subtitle>
                <template>{{Model.labelPlural}}</template>
            </subtitle>
            <actions>
                <action type="savecancel" afterCancel="/{{Model.KeyPrefix}}/o" afterSave="/{{Id}}" rollbackonanyerror="true" uniqueid="sk-uji7s-90"/>
            </actions>
        </pagetitle>
        <basicfieldeditor showsavecancel="false" showheader="true" model="Event" mode="edit" uniqueid="sk-uji85-100">
            <columns>
                <column width="50%">
                    <sections>
                        <section title="Basics" collapsible="no">
                            <fields>
                                <field id="Subject" uniqueid="sk-uji7z-97"/>
                                <field uniqueid="sk-ujlGQ-130" id="StartDateTime" valuehalign="" type=""/>
                                <field uniqueid="sk-ujlGQ-129" id="EndDateTime"/>
                            </fields>
                        </section>
                    </sections>
                </column>
                <column width="50%">
                    <sections>
                        <section title="Additional Info">
                            <fields/>
                        </section>
                    </sections>
                </column>
            </columns>
        </basicfieldeditor>
    </components>
    <resources>
        <labels/>
        <css/>
        <javascript/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>

Thanks,

Bill

Hey Bill,

That works if the StartDateTime field isn’t being override to a date field. I am trying to hide the HH:SS AM/PM from the user since we only care about a date so I’ve converted StartDateTime to a date field.  If I leave it as DateTime it saves perfectly. Any idea how to get past this error while leave the StartDateTime field as a Date? 

Josef,

I would add a UIOnly date field to your page.  In your Save actions use this UIOnly field to update the StartDateTime field before you save the Event model.  I think this will work.

Thanks,

Bill

Josef,

I think you will need to convert your Date Only UI field to a Date/Time field for the StartDateTime.  If you don’t set a time, its possible that the StartDateTime will end up on the previous or next day.  Here is the formula for a Model UI Only field to set the ‘time’ to 12PM.  Use this formatted Datetime field to update your StartDateTime.

YEAR({{DateOnly}})+‘-’+MONTH({{DateOnly}})+‘-’+DAY({{DateOnly}})+'T12:00:00Z

Thanks,

Bill

Thanks for all the help, Bill.

One of my initial thoughts was to use a UI date field and that kind of brings us full circle back to this post: http://community.skuid.com/skuid/top…

I would essentially need to keep the UI field in sync with the StartDateTime field so that the users could see the actual date of the events and be able to edit them accordingly.

I could do this with a workflow and another date field used as a simple data entry point that then writes to the StartDateTime field, but I was trying to avoid workflow if possible.

My workaround for now was to create a process builder that uses a custom date field(Meeting_Date__c) as the entry point and then convert that date field to datetime based off of the user’s current time zone. 

For anyone that is curious:

  • User formula field to capture the user’s timezone: (VALUE(MID(Time_Zone__c, 5, 3))) * (-1) / 24
  • Process builder conversion to convert custom date field to datetime at 12:00AM: DATETIMEVALUE([Event].Meeting_Date__c )+(($User.User_Timezone_Conversion__c )+0.04167)

If anyone can solve this without process builder I would greatly prefer to go that route.