I am using a drawer to display tasks related to a custom object. My drawer contains a table, and I’m using Context conditions on the table to display the appropriate tasks. (WhatId of Records = Id of row in context.) When I create a new row in the Tasks table, the WhatId is automatically populated with the Id of the row in context - which is exactly what I want to happen.
I also want to populate the WhoId of my new tasks using a custom field (Contact__c) on the row in context. The difficulty is that I want this field to be editable.
What’s the best way to set a default value in a new row in a drawer, and allow it to be editable? If it’s a snippet, how do I get the Id of the row in context?
If you’re running the create row as a row action I believe that the row in context gets passed into the snippet. Try putting a
console.log(arguments);
in the beginning of your snippet and see what you get. I think it’g going to be something like this:
var params = argumentse0],<br> model = params.model,<br> item = params.item,<br> row = item.row;<br>console.log(row); // should be the row you want
While Moshe was thinking in code, I was thinking declaratively. But ran into a problem.
If you are using the following method to pass the contactID into the Who ID, you should be able to subsequently edit the value.
- On your Task model add a condition on WhoId that is filterable default off.
- Add a second condition on Who.Name that is filterable default off.
- In your “Before Load Actions” on the drawer have a sequnece as follows:
- Activate the WhoId condition and give it the value of the contact_c from the row in context.
- Activate the Who.Name condition and give it the value of the contact__r.Name field from the row in context.
- Query the Task model (but Merges in new Rows into the existing set)
Now we run into a problem. When you add a new task inside the drawer, and go to edit the WhoId - we throw a javascript error because the WhoId is a polymorphic field. We are working to fix this bug, but I think you can get around the issue if you force the WhoId always to refer to a Contact record. Here is a post describing how to do that.
Thanks to both of you!
Rob, I did what you said and it works perfectly. I already had a custom snippet running on the contact to define WhoId, so - no errors.
Sweet!!!
Thank you both!!! Saved me a ton of time!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.