You need to sign in to do that
Don't have an account?
Urgent help needed with custom button.....Please
HI..
I am trying to write a custom button with Onclick javascript..
On click of button on OpportunityLineItem i want value from my custom field to be copied to standard field(Unit price)
Here is my code...
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
Var OppId={!GETRECORDIDS( $ObjectType.OpportunityLineItem )};
var Opp = new sforce.SObject("OpportunityLineItem");
Opp.Id = OppId ;
Opp.UnitPrice = "{!OpportunityLineItem.Customfield__c }",replace ',' -->;
updateRecords.push(Opp);
result = sforce.connection.update(updateRecords);
I get Unexpected identifier when i click on the button...
Please help
Thanks
I got the solution...This worked....
If any1 need it....
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var newRecords = [];
records = {!GETRECORDIDS($ObjectType.stdObject/customObject)};
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("StdObject/custom object");
c.id = records[n];
var qr = sforce.connection.query("Select customfield__c From StdObject where id ='"+c.id+"' ") ;
r = qr.getArray("records");
if (records.length > 0)
{
var price = r[0].get("customfield__c");
c.stdfield/field i want to update= price;
}
newRecords.push(c);
}
result = sforce.connection.update(newRecords);
window.location.reload();
All Answers
Hi There,
You can achieve this funcitoanlity in VF page by using "document.GetElementByID" to get the custom field value and you can update standard field.
Let me know if you need further help.
Thakns,
RajSF
But it is a standard page....And i am using professional....custom button will not help???
On top of everything...Can i update UnitPrice???
I remember Professional edition doesn't support API. You can't do this with custom button.
But its like writing Javascript....I am having Mass delete custom button in my organization...and it works perfect....
The javascript unexpected identifiier error is likely from this line.
If you want to use replace method, syntax is something like
but if you only want to retrieve the custom field value try
I tired that..and it errored out saying
Error: {faultcode:'soapenv:Client', faultstring:''' is not valid for the type xsd:double', }
So i used that ..
Thanks
I got the solution...This worked....
If any1 need it....
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}
var newRecords = [];
records = {!GETRECORDIDS($ObjectType.stdObject/customObject)};
for (var n=0; n<records.length; n++) {
var c = new sforce.SObject("StdObject/custom object");
c.id = records[n];
var qr = sforce.connection.query("Select customfield__c From StdObject where id ='"+c.id+"' ") ;
r = qr.getArray("records");
if (records.length > 0)
{
var price = r[0].get("customfield__c");
c.stdfield/field i want to update= price;
}
newRecords.push(c);
}
result = sforce.connection.update(newRecords);
window.location.reload();