You need to sign in to do that
Don't have an account?
b.gonzalez
OnClick JavaScript custom close button on case object?
I am not sure how to write a OnClick JavaScript custom close button on case object.
When the user clicks on this custom button, the following fields need to be updated with the given values.
Fields on case object:
Product Family = Unknown
Product Model = Unknown
Problem Code = Non-Technical
Resolution Code = Spam
Status = Closed
Resolution Description = Spam
Account Name (lookup field) = Unclassified Customer – Minnetonka
Also need to associate the contact to the account; Unclassified Customer – Minnetonka
I appreciate the help!
Beth
When the user clicks on this custom button, the following fields need to be updated with the given values.
Fields on case object:
Product Family = Unknown
Product Model = Unknown
Problem Code = Non-Technical
Resolution Code = Spam
Status = Closed
Resolution Description = Spam
Account Name (lookup field) = Unclassified Customer – Minnetonka
Also need to associate the contact to the account; Unclassified Customer – Minnetonka
I appreciate the help!
Beth
use below code chek if it is updating or not ?
Thanks
All Answers
You mean you want to create one custom button on case detail page and when we click on that button then it shgould asign the above values to that specific object right ??
for this you can create a detail page button on that object and then you can simply update the same object with above values..
Let me know if you need any help in this..
Thanks,
Sandeep
please check below link adn let me know if it helps you..
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008ogFIAQ
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
Thank you for responding to my question. That is correct.
If you could please help me I would appreciate. I am not sure how to start writing the button.
Thanks.
Beth
Following are the steps to achieve this..
1. Go to setup and type case and then click on button and links ..
2. Click new button and link and then provide the Label and name adn also select *Detail page button*.
3. Select Behaviour as executeJavascript and Content source as onclickjavascript..
4. then paste below code to script section
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var record = new sforce.SObject("Case");
record.Id = "{!Case.Id}";
record.Type= 'Other';
var result = sforce.connection.update([record]);
// check the result here
window.location.reload();
this is a example code which will update the type field to other when you click on the button adn it will reload the page with latets values..you can addd all your fields and provid ethe values ...
5. Also you just need to go to case page layout and add the custom button there ..
Please check with these adn let me knwo if it helps ..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
Thank you. I am experiencing an issue with when clickinig the button: Unexpected end of input.
Here is the script:
Please advise.
Thanks!
Beth
Use below code:
let me know if it helps..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
I applied the code below and performed a test. The button is not working, the fields listed in the code on the contact record are not being update and the case is being closed.
Beth
These fields are on Contact or Case ? Based on current code it is taking current fields as case fields and try to update ...
Initally whatever code I haev given if you ahev tried that then that was updating case fields...if you want to update other objects then you need to first query them and then you need to update them..
Let me know exactly what you need...
Thanks
use below code chek if it is updating or not ?
Thanks
Beth
So what you need? you need tos et status as closed or in condition you need to check if its not closed then only update ?
Thanks
Beth
Have you tried
record.status = 'Closed';
check with this and let me know if it helps..
Thanks
setup-->case--?support setting-->chek Show Closed Statuses in Case Status Field then this closed status value will be visible in picklist and as I mentioned you will be able to simply update the field using
record.status = 'Closed';
Please check and let m eknow..
P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
Thanks,
Sandeep
Salesforce Certified Developer
Beth
could you please tell me, how I could return to the "All Cases" page and not on the Case that is closed.
Thanks and regards
Kailash
Try the following snippet: - make sure to insert the proper URL for the window.location.href:
if (sforce.console.isInConsole()){
isConsoleTest = true;
}
else{
window.location.href = "https://developer.salesforce.com/forums/?id=906F0000000BJ0zIAG";
}
function testCloseTab() {
//First find the ID of the current primary tab to close it
sforce.console.getEnclosingPrimaryTabId(closeSubtab);
}
var closeSubtab = function closeSubtab(result) {
//Now that we have the primary tab ID, we can close it
var tabId = result.id;
sforce.console.closeTab(tabId);
};
if(isConsoleTest){
testCloseTab();
}
Instead of hard coding you can just redirect it to that page using prefix which is constant in all the orgs...
/500/o...u can redirect it to this url then it will show you all teh cases....
Please check and let me know if that helps you.
Thanks,
Sandeep
------------------------------------------
{!REQUIRESCRIPT('/soap/ajax/40.0/connection.js')}
{!REQUIRESCRIPT("/soap/ajax/40.0/apex.js")}
var caseIds = {!GETRECORDIDS($ObjectType.Case)};
var cases = [], TCase, result;
while(caseIds.length) {
TCase = new sforce.SObject('Case');
TCase.Id = caseIds.shift();
TCase.Delete__c= 'Purge';
cases.push(TCase);
}
result = sforce.connection.update(cases);
window.top.location.href = window.top.location.href;
---------------------------------------------------------
Any help is appreciated.
I'm having the same situation, in "license users" everithing is working properly. But when I try to press any javascript button from a Site the button show me this message:
"EntityObject cannot be initialized with null EntityInfo"
Every button in my organization its having this problem, I try to change the API version to 29, 40 and nothing works.