• DPhil
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 13
    Replies
I'm using a custom button to create a new record in a custom object, but the code is failing when I try to insert a value which is type currency during the process.

I have created a custom object called "Project" with an api name of "Production__c".

I have added a custom button to the Opportunity page to create a new Project record and pre-populate it with some fields from the Opportunity.

It works fine until I try to add a value from a currency field, at which point it fails.

If I use no quotes around the value it gives the error "Unexpected number", if I use quotes around it then it give the error "'GBP 1,250' is not valid for the type xsd:double".

So I can't work out how to get the type right, any help would be much appreciated!

Here is the code:

==========

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

var Proj = new sforce.SObject("Production__c");

Proj.Name = "{!Opportunity.Name}";
//Proj.Monthly_Revenue__c = 1234; **This works**
//Proj.Monthly_Revenue__c = '{!Opportunity.Monthly_Revenue__c}'; **This gives error 'GBP 1,250' not valid for type: xsd:double**
//Proj.Monthly_Revenue__c = {!Opportunity.Monthly_Revenue__c}; **This gives error 'unexpected number'**

result = sforce.connection.create([Proj]);

if(result[0].success == 'true'){
    window.location = "/" + result[0].id + "/e";}
else {alert("Error creating Project");}

============
  • July 31, 2014
  • Like
  • 0
I'm using a custom button to create a new record in a custom object, but the code is failing when I try to insert a date during the process.

I have created a custom object called "Project" with an api name of "Production__c".

I have added a custom button to the Opportunity page to create a new Project record and pre-populate it with some fields from the Opportunity. 

I'm trying to copy a custom date value from Opportunty to the Project record, but it fails with an error: "[faultcode:'soapenv:Client',
faultstring:"0.0022343594836146973' is not a valid value for the type xsd:date', }".

Here is the code:

==========

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

var Proj = new sforce.SObject("Production__c");

Proj.Name = "{!Opportunity.Id}";
Proj.Account_Name__c = "{!Opportunity.AccountID}";
Proj.Opportunity_Name__c = "{!Opportunity.Name}";
Proj.Date_Signed__c = {!Opportunity.Date_Signed__c};

result = sforce.connection.create([Proj]);

if(result[0].success == 'true'){
    window.location = "/" + result[0].id + "/e";}
else {alert("Error creating Project");}

==========

Any help would be appreciated! Thanks.
  • July 24, 2014
  • Like
  • 0
I need to create some custom buttons with Javascript, but I can't find any tutorial/API documentation as it applies to custom buttons.

I'm on PE, so can't use Apex as I understand.

Can someone point me in the right direction to any documentation resources please?

Thanks
  • July 24, 2014
  • Like
  • 0
I'm trying to use a custom button to create a new record in a custom object, but the code is failing, I would appreciate some advice?

I'm new to this and can't find a good reference to the Javascript toolkit/api, so I'm reduced to Googling for answers and can't figure it out.

I have created a custom object called "Project" with an api name of "Porduction__c".

I want to add a custom button to the Opportunity page to create a new Project record and pre-populate it with some fields from the Opportunity.  Then it takes the user to the record so they can edit and save it.

I did have it working, but then I added a master-detail relationship between Project and Account, plus a lookup field relationship between Project and Opportunity, after which it stoped working.

I have added the required fields to the new record object, so I don't think that's the issue.

I can't work out how to get a meaningful error message.

Here is the code:

==========

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

var Proj = new sforce.SObject("Production__c");

Proj.Name = "{!Opportunity.Name}";
Proj.Account_Name__c = "{!Opportunity.Account}";
Proj.Opportunity_Name__c = "{!Opportunity.Name}";

result = sforce.connection.create([Proj]);

if(result[0].success == 'true'){
    window.location = "/" + result[0].id + "/e";}
else {alert("Error creating Project");}

=============

Any help much appreciated!
  • July 24, 2014
  • Like
  • 0
I'm using a custom button to create a new record in a custom object, but the code is failing when I try to insert a value which is type currency during the process.

I have created a custom object called "Project" with an api name of "Production__c".

I have added a custom button to the Opportunity page to create a new Project record and pre-populate it with some fields from the Opportunity.

It works fine until I try to add a value from a currency field, at which point it fails.

If I use no quotes around the value it gives the error "Unexpected number", if I use quotes around it then it give the error "'GBP 1,250' is not valid for the type xsd:double".

So I can't work out how to get the type right, any help would be much appreciated!

Here is the code:

==========

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

var Proj = new sforce.SObject("Production__c");

Proj.Name = "{!Opportunity.Name}";
//Proj.Monthly_Revenue__c = 1234; **This works**
//Proj.Monthly_Revenue__c = '{!Opportunity.Monthly_Revenue__c}'; **This gives error 'GBP 1,250' not valid for type: xsd:double**
//Proj.Monthly_Revenue__c = {!Opportunity.Monthly_Revenue__c}; **This gives error 'unexpected number'**

result = sforce.connection.create([Proj]);

if(result[0].success == 'true'){
    window.location = "/" + result[0].id + "/e";}
else {alert("Error creating Project");}

============
  • July 31, 2014
  • Like
  • 0
I'm using a custom button to create a new record in a custom object, but the code is failing when I try to insert a date during the process.

I have created a custom object called "Project" with an api name of "Production__c".

I have added a custom button to the Opportunity page to create a new Project record and pre-populate it with some fields from the Opportunity. 

I'm trying to copy a custom date value from Opportunty to the Project record, but it fails with an error: "[faultcode:'soapenv:Client',
faultstring:"0.0022343594836146973' is not a valid value for the type xsd:date', }".

Here is the code:

==========

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

var Proj = new sforce.SObject("Production__c");

Proj.Name = "{!Opportunity.Id}";
Proj.Account_Name__c = "{!Opportunity.AccountID}";
Proj.Opportunity_Name__c = "{!Opportunity.Name}";
Proj.Date_Signed__c = {!Opportunity.Date_Signed__c};

result = sforce.connection.create([Proj]);

if(result[0].success == 'true'){
    window.location = "/" + result[0].id + "/e";}
else {alert("Error creating Project");}

==========

Any help would be appreciated! Thanks.
  • July 24, 2014
  • Like
  • 0
I need to create some custom buttons with Javascript, but I can't find any tutorial/API documentation as it applies to custom buttons.

I'm on PE, so can't use Apex as I understand.

Can someone point me in the right direction to any documentation resources please?

Thanks
  • July 24, 2014
  • Like
  • 0
I'm trying to use a custom button to create a new record in a custom object, but the code is failing, I would appreciate some advice?

I'm new to this and can't find a good reference to the Javascript toolkit/api, so I'm reduced to Googling for answers and can't figure it out.

I have created a custom object called "Project" with an api name of "Porduction__c".

I want to add a custom button to the Opportunity page to create a new Project record and pre-populate it with some fields from the Opportunity.  Then it takes the user to the record so they can edit and save it.

I did have it working, but then I added a master-detail relationship between Project and Account, plus a lookup field relationship between Project and Opportunity, after which it stoped working.

I have added the required fields to the new record object, so I don't think that's the issue.

I can't work out how to get a meaningful error message.

Here is the code:

==========

{!REQUIRESCRIPT('/soap/ajax/27.0/connection.js')}

var Proj = new sforce.SObject("Production__c");

Proj.Name = "{!Opportunity.Name}";
Proj.Account_Name__c = "{!Opportunity.Account}";
Proj.Opportunity_Name__c = "{!Opportunity.Name}";

result = sforce.connection.create([Proj]);

if(result[0].success == 'true'){
    window.location = "/" + result[0].id + "/e";}
else {alert("Error creating Project");}

=============

Any help much appreciated!
  • July 24, 2014
  • Like
  • 0