You need to sign in to do that
Don't have an account?
Steve Harrison
onclick javascript to update Status
I am in need of onclick javascript for a custom button on the order detail record that changes the Status picklist option to "Cancelled"
Thanks in advance
Steve
Thanks in advance
Steve
I named it "Cancel Order" and set it as a "Detail Page Button" (so it's available for use ona detail record).
Behavior is "Execute JavaScript" and Content Source is "OnClick JavaScript".
I've pasted in the Javascript code I put in my formula box:
var o = new sforce.SObject("Order");
o.id ="{!Order.Id}";
function checkError(result)
{
if (!result[0].getBoolean('success')) {
throw("error");
}
}
try
{
o.status = "Cancelled";
result = sforce.connection.update([o]);
checkError(result);
alert("Order cancelled!");
}
catch (err)
{
alert('An error occurred processing your request. Please contact your administrator and reference order ID '+o.id);
}
Now edit the desired page layout and choose "Buttons" and place your custom button like so:
Now when you edit an Order record you should see the button and, if all goes well, get an alert that says "Order cancelled!"
Hope this helps!
All Answers
I named it "Cancel Order" and set it as a "Detail Page Button" (so it's available for use ona detail record).
Behavior is "Execute JavaScript" and Content Source is "OnClick JavaScript".
I've pasted in the Javascript code I put in my formula box:
var o = new sforce.SObject("Order");
o.id ="{!Order.Id}";
function checkError(result)
{
if (!result[0].getBoolean('success')) {
throw("error");
}
}
try
{
o.status = "Cancelled";
result = sforce.connection.update([o]);
checkError(result);
alert("Order cancelled!");
}
catch (err)
{
alert('An error occurred processing your request. Please contact your administrator and reference order ID '+o.id);
}
Now edit the desired page layout and choose "Buttons" and place your custom button like so:
Now when you edit an Order record you should see the button and, if all goes well, get an alert that says "Order cancelled!"
Hope this helps!