You need to sign in to do that
Don't have an account?
Ronnie Paton 8
xsd:Date
Hi All,
I am trying to create a button that converts a case to an opportunity, but have ran into a bit of a brickwall
When I click the button I get the following error
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:,soapenv:Client',faultstring:"03/08/2014' is not a valid value for the type xsd:date',}
The status of the case changes but the opportunity is not created, here is the code I have but not sure if it works totally as can't get past the date issue.
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.Status = 'Converted to Opportunity';
var result = sforce.connection.update([caseObj]);
var status = "{!Case.Status}}";
var newRecords = [];
{
var o = new sforce.SObject("Opportunity");
o.AccountId = '{!Case.AccountId}';
o.Type = '{!Case.Type}';
o.Name = '{!Case.CaseNumber},{!Case.Subject}';
o.LeadSource = '{!'Converted from Case'}';
o.Description = '{! Case.Description }';
o.OwnerId = '{!Account.OwnerId}';
o.StageName = '{!'Perception Analysis'}';
o.CloseDate = '{! TODAY() +30}';
newRecords.push(o);
}
var result = sforce.connection.create(newRecords);
if (result[0].success == 'false') {
alert(result[0].errors.message);
} else {
parent.ID = '{!Case.ParentId}';
window.parent.location = ('/00a/e?parent_id=retURL=/{!Case.Id}');}
I know the issue is from the o.CloseDate = '{! TODAY() +30}'; but just can't workout what it should be.
Thanks
I am trying to create a button that converts a case to an opportunity, but have ran into a bit of a brickwall
When I click the button I get the following error
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:,soapenv:Client',faultstring:"03/08/2014' is not a valid value for the type xsd:date',}
The status of the case changes but the opportunity is not created, here is the code I have but not sure if it works totally as can't get past the date issue.
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var caseObj = new sforce.SObject("Case");
caseObj.Id = '{!Case.Id}';
caseObj.Status = 'Converted to Opportunity';
var result = sforce.connection.update([caseObj]);
var status = "{!Case.Status}}";
var newRecords = [];
{
var o = new sforce.SObject("Opportunity");
o.AccountId = '{!Case.AccountId}';
o.Type = '{!Case.Type}';
o.Name = '{!Case.CaseNumber},{!Case.Subject}';
o.LeadSource = '{!'Converted from Case'}';
o.Description = '{! Case.Description }';
o.OwnerId = '{!Account.OwnerId}';
o.StageName = '{!'Perception Analysis'}';
o.CloseDate = '{! TODAY() +30}';
newRecords.push(o);
}
var result = sforce.connection.create(newRecords);
if (result[0].success == 'false') {
alert(result[0].errors.message);
} else {
parent.ID = '{!Case.ParentId}';
window.parent.location = ('/00a/e?parent_id=retURL=/{!Case.Id}');}
I know the issue is from the o.CloseDate = '{! TODAY() +30}'; but just can't workout what it should be.
Thanks
dt = new Date();
dt.setDate(dt.getDate() + 30);
o.CloseDate = dt;
All Answers
dt = new Date();
dt.setDate(dt.getDate() + 30);
o.CloseDate = dt;