Skip to main content

I want my users to be able to click on the “+” sign in a calendar (month) view and create a new record in my model for that day. One of the fields that needs to be populated is a lookup to a record that corresponds to the date they selected. The user shouldn’t have to re-select the date, though, so how do I pre-populate that field in my pop-up with the date that was clicked on?

Since Skuid currenly only supports selecting Datetime fields, not Dates, for a Calendar Event Source’s Start Field / End Field, I’m assuming that you have already created such Datetime fields in order to have gotten this far, so what I would recommend is not having the Session Day field in your custom Event Source popup at all, and populating it after-save via a Workflow Field Update based on the value in your Start Datetime field. If that’s not an option, there’s a couple of quick JavaScript approaches we could suggest that would could populate Session Day behind the scenes so that it would be populated when you save your record.


The Session Day is the key component and why I’m using a calendar at all for this, so it is necessary. Since it is a lookup field, I can’t just populate the field with workflow, either. All three fields in the top row are actually already known, given the chosen date, so I don’t want users to have to choose them at all, normally. I’m not opposed to using JavaScript with an on-save action, but I don’t know how to reference the date. I assume that the date that was clicked on is in context somewhere? (It would be really cool to be able to use it declaratively!)


Actually, what I really need to do is render the page differently based on the date chosen. I’m thinking I may need to pass the date into the popup and use an include page there to access other models based on that date (& other context/user info I can get, like the class). That seems to get me where I really need to be.


I figured out how to get this to happen! I configured the event source to run a snippet before displaying my “new record” popup. The javascript: 1) gets the date/time 2) converts it to a date 3) sticks that date into a second model’s conditions 4) refreshes the data for that second model. This second model is the source for my “Session Day” picklist, which then has the correct record populated in it. Below is the javascript snippet.


var params = arguments 0], $ = skuid.$, chosenSFDateTime = params.eventr'Date_Time__c'], chosenJDateTime = skuid.time.parseSFDateTime(chosenSFDateTime); chosenSFDate = skuid.time.getSFDate(chosenJDateTime), sdModel = skuid.model.getModel('SessionDay'), sdDateCondition = sdModel.getConditionByName('SessionDayDate'); sdModel.setCondition(sdDateCondition,chosenSFDate); sdModel.updateData(); 

Reply