You need to sign in to do that
Don't have an account?
louisa barrett 7
Set picklist value on case page load
Hi,
I have a requirement to set the value of a picklist field when the case page loads. The value is dependent on a field from the asset that has been added. I can get it to update once the page is saved using a process, but this slows down the process of booking a case dramatically. Does anyone know of a way that I can populate a picklist value on the page load based on a field from a look up.
Business Case:
An asset has a picklist field named 'Product Type'.
The case object has a picklist field named 'Fault Category 1'.
Both of these fields have the same values.
From the asset, when a case is created I need the Fault Cateogory 1 field on the case to automatically select the same value as the Asset.Product_Type__c
Currently I used the process builder to update the Fault Category 1 field, but that does not fire until the user presses Save on the case object.
Is there a way using Jquery, AJAX or any other method that this can be acheived?
Many thanks
I have a requirement to set the value of a picklist field when the case page loads. The value is dependent on a field from the asset that has been added. I can get it to update once the page is saved using a process, but this slows down the process of booking a case dramatically. Does anyone know of a way that I can populate a picklist value on the page load based on a field from a look up.
Business Case:
An asset has a picklist field named 'Product Type'.
The case object has a picklist field named 'Fault Category 1'.
Both of these fields have the same values.
From the asset, when a case is created I need the Fault Cateogory 1 field on the case to automatically select the same value as the Asset.Product_Type__c
Currently I used the process builder to update the Fault Category 1 field, but that does not fire until the user presses Save on the case object.
Is there a way using Jquery, AJAX or any other method that this can be acheived?
Many thanks
Hi Louisa,
One way I see you can achieve this is by using a custom button on the related list for Cases on the Asset detail page and url hacking.
Url hack can be used to pre-populates values on any fields on the create/edit page.
Create this button as a javascript button (List Button on Case object)
Button Code
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var AssetId = '{!Asset.Id}'; // Select Asset object's Id from Select Field Type picklist on button editor
var AssetName = '{!Asset.Name}'; // similarly select asset name
var ProdType = '{!Asset.ldapp__TEST__c}'; // similarly select the picklist you desire
window.open("/500/e?retURL="+AssetId+"&00N9000000AiqKW="+ProdType+"&Asset_lkid="+AssetId+"&Asset="+AssetName,"_parent");
3 Important Parameters
00N9000000AiqKW
Asset_lkid
Asset
1. 00N9000000AiqKW = Id of the picklist field on Case object that needs to be auto-populated. Go to Setup->Customize->Case->Fields->DesiredFieldName. In the url you will find the id of the field, always starts with 00N for all custom fields. For standard fields go to the edit mode of the any record and then use inspect element to check the id
2. Every lookup fields must be specified 2 values
a. Asset_lkid (fieldsId_lkid is used to set the actual if of the record)
b. Asset (fieldId is used to set the text value of the record)
Thanks
Vivian
All Answers
We can prepopulate field values while creating new record by passing these values in URL. More info at http://writeforce.blogspot.in/2012/12/prepopulating-fields-using-url-hacking.html
Follow below steps
1) Create custom button on case - List Button with Behavior: Display in existing window without sidebar and header, with URL like
Observe last parameter in the URL which is Id of the Select element (picklist on case layout) and the desired value you want to set. In your case you would need to get your desired value from asset object, you can get merge field for the value from formula builder where you will construct your url like above. You can get id of select element from chrome broswer developer console through "Inspect Element".
2) Include this custom button on case related list on asset object page layout.
Let me know if this help you.
Hi Louisa,
One way I see you can achieve this is by using a custom button on the related list for Cases on the Asset detail page and url hacking.
Url hack can be used to pre-populates values on any fields on the create/edit page.
Create this button as a javascript button (List Button on Case object)
Button Code
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var AssetId = '{!Asset.Id}'; // Select Asset object's Id from Select Field Type picklist on button editor
var AssetName = '{!Asset.Name}'; // similarly select asset name
var ProdType = '{!Asset.ldapp__TEST__c}'; // similarly select the picklist you desire
window.open("/500/e?retURL="+AssetId+"&00N9000000AiqKW="+ProdType+"&Asset_lkid="+AssetId+"&Asset="+AssetName,"_parent");
3 Important Parameters
00N9000000AiqKW
Asset_lkid
Asset
1. 00N9000000AiqKW = Id of the picklist field on Case object that needs to be auto-populated. Go to Setup->Customize->Case->Fields->DesiredFieldName. In the url you will find the id of the field, always starts with 00N for all custom fields. For standard fields go to the edit mode of the any record and then use inspect element to check the id
2. Every lookup fields must be specified 2 values
a. Asset_lkid (fieldsId_lkid is used to set the actual if of the record)
b. Asset (fieldId is used to set the text value of the record)
Thanks
Vivian
I'll hopefully get chance to have a look at it this afternoon
That worked great thank you. The account and entitlement look ups aren't being populated on the case page now, so I've added them to the argument list, but I'm getting an error of 'Missing ) ' when I press the case button. I cannot spot the error
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var AssetId = '{!Asset.Id}'; // Select Asset object's Id from Select Field Type picklist on button editor
var AssetName = '{!Asset.Name}'; // similarly select asset name
var ProdType = '{!Asset.Product_Type__c}'; // similarly select the picklist you desire
var AccountID = '{!Account.Id}'; //Account ID
var AccountName = '{!Account.Name}'; //Account Name
var EntitlementID = '{!Account.Entitlement_Id__c}'; //Entitlement ID
var EntitlementName = '{!Account.Entitlement_Name__c}'; //Entitlement Name
window.open("/500/e?retURL="+AssetId+"&00N260000010Il9="+ProdType+"&Asset_lkid="+AssetId+"&Asset="+AssetName"&Account_lkid="+AccountID+"&Account="+AccountName+"&Entitlement_lkid="+EntitlementID+"&Entitlement="+EntitlementName,"_parent");
Many thanks
Hi Louisa,
I believe you have missed a + symbol after the AssetName variable
Your button reads +AssetName" instead of +AssetName+"
Thanks
Vivian
My account and entitlements are still not being populated though. I've tried using the Account name field ID (or t least I think it is), acc2_ilecell, instead of Account_lkid
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var AssetId = '{!Asset.Id}'; // Select Asset object's Id from Select Field Type picklist on button editor
var AssetName = '{!Asset.Name}'; // similarly select asset name
var ProdType = '{!Asset.Product_Type__c}'; // similarly select the picklist you desire
var AccountID = '{!Account.Id}'; //Account ID
var AccountName = '{!Account.Name}'; //Account Name
var EntitlementID = '{!Account.Entitlement_Id__c}'; //Entitlement ID
var EntitlementName = '{!Account.Entitlement_Name__c}'; //Entitlement Name
window.open("/500/e?retURL="+AssetId+"&00N260000010Il9="+ProdType+"&Asset_lkid="+AssetId+"&Asset="+AssetName+"&acc2_ilecell="+AccountID+"&Account="+AccountName+"&Entitlement_lkid="+EntitlementID+"&Entitlement="+EntitlementName,"_parent");
Louisa,
I was able to populate all the lookup's properly with the following code. Please use alert() to check if you have received any values in the respective variables. Go to the create/edit page of the Case object. Right click on the lookup field, and select Inspect. This will give you details of the field as follows
<input id="Entitlement" maxlength="255" name="Entitlement" onchange="getElementByIdCS('Entitlement_lkid').value='';getElementByIdCS('Entitlement_mod').value='1';" size="20" tabindex="11" type="text" value="">
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var AssetId = '{!Asset.Id}';
var AssetName = '{!Asset.Name}';
var ProdType = '{!Asset.Status}';
var AccountID = '{!Account.Id}';
var AccountName = '{!Account.Name}';
var EntitlementID = '{!Account.EntitlementId__c}';
var EntitlementName = '{!Account.Entitlement__c}';
alert(AccountID);
alert(EntitlementID);
alert(EntitlementName);
window.open("/500/e?retURL="+AssetId+"&00N260000010Il9="+ProdType+"&Asset_lkid="+AssetId+"&Asset="+AssetName+"&cas4_lkid="+AccountID+"&cas4="+AccountName+"&Entitlement_lkid="+EntitlementID+"&Entitlement="+EntitlementName,"_parent");
Note : The sandard account lookup field id is cas4
Thanks
Vivian
Thank you again
Louisa,
Note
1. Any field that needs to be auto-populated must always be on the layout. Any fields not on the layout cannot be auto-poopulated
2. Please check the field level security for Entitlement field on case, since some standard fields may not be available by default
In case you need any help feel free to send me your credentials so that I can assist you in, if needed. Feel free to mark the question as resolved so that it can help others facing the same issue.
Thanks
Vivian