Event Related Object Fields

I am using the Skuid Calendar extensively to track medical appointments between account and contacts (Doctors). I am also using it to track vehicle sign out for those appointments. The record name of the vehicles is the VIN number. The “whatid/name”, which is the VIN is not incredibly helpful for those looking at e calendar. People relate more to colors, makes and models. I have a concatenated_name__c field on the vehicle record which is the name I want to use “4903 Red Sienna 2014” or a Nickname field. Is there any creative ways to display these names on the “Event Template” of the calendar event? By default when using event I can’t access them. Is there any other trickery I can use to access them and display them on the calendar event using the “Event Template”? Thanks!

The VIN makes a great primary key and databases love it! Humans, however, are not so good with long alphanumeric strings, as you rightly point out.

Just roll your eyes at me if you’ve already done the following steps:

You should be able to use the merge syntax, {{concatenated_name__c}}. Assuming there is a lookup or master/detail relationship between the Event object and the object containing vehicle records, you’ll need to make sure you’ve checkmarked the concatenated field in the Event model by passing the lookup to the vehicle object to the concatenated field.

If you’ve already done that or this doesn’t work for you, then would mind providing a little more data that let’s me know about the relationship between the vehicle record (and its object) to the Event, Contact, or Account model.

-Josh

I guess what I am struggling with is… my understanding is Events are polymorphic and Salesforce locks it down pretty tight. I try to access the objects via merge syntax but from what I can tell I don’t have access to all the fields on the object through “WhatId” on the event.  In some cases like in formulas I don’t even have access to the Name I only have access to the ID.  

My thought/hope is that after my end users select the record they are connecting to through the “WhatId” I could have a Model linked to that field to take the ID and autofill some additional custom fields on the event.  Is that possible?

Another use case would be auto-populating “Location” on the Event using the Contact’s address. 


Any thoughts?

Rich,
You are right, Salesforce polymorphic fields are pretty tough to work with! :confused: I think you’re onto something with using two different models and getting the Id from the events model, but this solution is going to take some JavaScript. I’m working on something for you, so we’ll see how far I can get. I’ll keep you posted.
Emily

Ok, depending on whether you want to allow multiple types of Sobjects for your WhatId field, the solution could be more complicated. I worked on the simple case where you only update the event’s location based on an account’s (in your case, contact’s) address. Here’s what I did:

1.) Create your models (Events and Account). Your Account model should have a condition where Id = ‘’ (filterable as AcctId) (inactive). ALSO, in your advanced settings for Account, uncheck “Load Model Data on Page Load.”

2.) Use a custom popup window for your event source’s on-click behavior. In this popup, include all the fields necessary (including WhatId), and use a custom button to save the event (you can uncheck “Show Default Buttons in Popup” under “Configure On-Click Popup” if you want.


3.) The snippet for your custom button should include this code (but replace Account information with Contact information):

//If an event's WhatId points to an account, use the account's billing street as the event's location. var $ = skuid.$; //Get the events model and the event row in context var eventModel = skuid.model.getModel('Events'); var contextRow = arguments[0].component.component.context.row; //Get info about the account model var acctModel = skuid.model.getModel('Account'); var acctCondition = acctModel.getConditionByName('AcctId'); //Save the event model in order to get the WhatId eventModel.save({ callback: function(){ var eventWhatId = contextRow.WhatId; //Run this if an account is associated with the event's WHatId if (eventWhatId !== undefined &amp;&amp; eventWhatId !== null) { if (contextRow.What.Type == 'Account') { //Bring the event's account into the account model, and update the event's location acctModel.setCondition(acctCondition, eventWhatId); acctModel.activateCondition(acctCondition); acctModel.updateData(function(){ var account = acctModel.getFirstRow(); var acctAddress = account.BillingStreet; eventModel.updateRow(contextRow, {Location: acctAddress}); eventModel.save(); }); } } } }); //Close the popup $('.ui-dialog-content').dialog('destroy');<br>

 
Hope this is not more complicated than what you’re looking for. Currently, this is probably the best you can do! Let me know if you have any other questions.

Thanks for taking the time to look into that Emily!  I will give it a shot and see what I can do.