You need to sign in to do that
Don't have an account?
Javascript button to call method
Hi everyone,
I'm trying to learn on the fly here, my knowledge is more around triggers.
I'm trying to create a List button to automatically create three records, basically I'm trying to create my own grocery list and just automate a few items.
Class and Method:
Onclick Javascript button:
Error message
Everything I look up seems to reference passing parameters as part of the button, but I don't have anything to pass here.
I'm assuming that it's something obvious
Thanks very much
I'm trying to learn on the fly here, my knowledge is more around triggers.
I'm trying to create a List button to automatically create three records, basically I'm trying to create my own grocery list and just automate a few items.
Class and Method:
Global class addGroceries { WebService static void addSomeGroceries(){ List<Groceries__c> groc = new List<Groceries__c>(); Groceries__c g1 = new Groceries__c(Name='Garlic', Category__c='1 - Fruit and Vegetables'); groc.add(g1); Groceries__c g2 = new Groceries__c(Name='Onions', Category__c='1 - Fruit and Vegetables'); groc.add(g2); Groceries__c g3 = new Groceries__c(Name='Pears', Category__c='1 - Fruit and Vegetables'); groc.add(g3); insert groc; } }
Onclick Javascript button:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")} sforce.apex.execute("addGroceries","addSomeGroceries",{}); window.location.reload();
Error message
A problem with the OnClick JavaScript for this button or link was encountered: args not specified
Everything I look up seems to reference passing parameters as part of the button, but I don't have anything to pass here.
I'm assuming that it's something obvious
Thanks very much
Are you still facing this issue?? I recreated the same code and did not face any issue.
Thanks
Prakash
sforce.apex.execute("packageName/addGroceries","addSomeGroceries",{});
I converted it to a VF page instead and didn't have an issue.
Class and Button that do work:
Visualforce Page I'm calling from button instead
Still would love to know what I was doing wrong if the comparison helps anyone enough to get to the bottom of it