
Hello,
My setup:
What I need:
How can I set a default value of a quick create based on which subgrid i'm creating from? Is this possible?
Thank you.
Hi,
When you create a task from subgrid it opens Task Quick Create form and by default sets regarding field (parent). You can register a JavaScript function on load of the task quick create form, which sets the value based on entity type of regarding lookup.
Here is an example with steps:
function onLoad_Set_Task_Type(executionContext) {
var formContext = executionContext.getFormContext();
// Set value only on Create Form
if (formContext.ui.getFormType() == 1) {
var entityType, lookupFieldObj;
// Get Regarding Lookup Object
lookupFieldObj = formContext.data.entity.attributes.get("regardingobjectid");
if (lookupFieldObj.getValue() != null) {
entityType = lookupFieldObj.getValue()[0].entityType;
// Set value based on regarding entity
if (entityType == "account") {
formContext.data.entity.attributes.get("new_whocalledme").setValue(100000000);
} else if (entityType == "opportunity") {
formContext.data.entity.attributes.get("new_whocalledme").setValue(100000001);
} else {
formContext.data.entity.attributes.get("new_whocalledme").setValue(100000002);
}
}
}
}
When task created from Account
When task created from Opportunity
I hope this solves your problem.
Best,
Wahaj
(if it helped, mark it verified)