Skip to main content

When in-line creating and entering a new completed activity on a Lead detail page (call, email, web conference), I would like it if I didn’t have to select the picklist values for Owner ID, Status, Priority and Date every time. How can I set the picklist values to a default (my ID, completed, normal and today’s date, respectively) whenever I create a new completed activity?

Matt, If you use a “clone” button, it should create a new record and copy all the values selected in the existing record into it. This works great and really cuts down on the data entry.


That’s a good workaround, but it would be great to be able to set global actions which populate default text in the fields to help the user automate typing on the fly.


We did it! I can now click on a global action for a new task of a certain type (completed call, email, etc.) and it autopopulates the values for everything but the subject or description field. This lets me quickly enter the data in between calls and meetings. Thank you to Zach for writing a custom snippet - we created a global action for each of the different types of tasks (Call, Voicemail, Email, etc. - these are values on a custom field, Type__c), and used a custom snippet as the main resource for each action, along with another snippet for each task type. The main snippet: var TaskModel = skuid.model.getModel(‘TaskHistory’); var self = argumentse0]; var $ = skuid.$; // Create a new Task in our Task Model var NewTask = TaskModel.createRow({ initiatorId : self.list._GUID, additionalConditions : self.list.options.conditions }); var defaults = { ‘Priority’:‘Normal’, ‘Status’:‘Completed’, ‘OwnerId’: skuid.utils.userInfo.userId, ‘Owner.Name’: skuid.utils.userInfo.userName, ‘ActivityDate’: skuid.time.getSFDate(new Date()) }; if (self.defaults) { $.extend(defaults,self.defaults); } TaskModel.updateRow(NewTask,defaults); // Create a new Item in our Table (wrapper around the new Task row) var newItem = self.list.newItem( NewTask, { editModeForNewItems : true } ); self.list.render({ resetPagination : true ,refreshFields : false }); // Focus on the Subject field $.each(newItem.fields,function(){ if (this.id === ‘Subject’){ var inputElement = this.element.find(‘:input’).first(); inputElement && inputElement.focus(); } }); Once this was taken care of, we were able to write the smaller snippet that would correspond to each global action: var params = argumentsc0]; // This is where you set the defaults you want params.defaults = { ‘Type__c’:‘Call’ }; skuid.snippet.getSnippet(‘NewCompletedTask’)(params); It’s a small thing, but I hope it’s helpful. Thanks Zach!


Woo!


Now that I’ve got these great custom global actions on the Lead Detail page that autopopulate field values, I’m wondering if I can take it one more level. Is it possible to have individual global action buttons instead of them all being in a dropdown picklist? So, there’d just be a PHC (phone call complete) button sitting up there that I can just click and it adds the record w/ autopopulated values.


Currently all Table Global Actions show up in a single drop-down list, no way around that. However, you could implement these as separate Page Title Actions instead, then you could have them separated out. Not ideal.


Gotcha, thanks.


Matt, This script is awesome. Is there any way to modify it slightly to have the user enter the data in a popup rather than inline? I have many uses for the inline, but there are some situations where you would want the popup window to pre-format values in the same way. Thanks for the code!


That’s a good question, and definitely one for Zach or another developer. I’ll ask around.


Matt, Another question: When I try to populate the owner field on a custom object, it just inserts the ID into the field. I assume this is because the Owner field on a custom object is polymorphic to the User and Group objects. Do you know any way around this? Thanks again! Greg


Matt this seems to have fixed itself when I changed the type to picklist, and ran the ID through a filter which looks at a model with active users in it.