You need to sign in to do that
Don't have an account?
Ronnie Paton 8
Oneclick java script issues
HI,
I am trying to create a custom button on a custom Object that when clicked creates Account\Contact\Opportunity (like convert button on Lead).
The code I have is
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var ProspectObj = new sforce.SObject("Prospect__c");
ProspectObj.ID = '{!Prospect__c.Id}';
ProspectObj.Converted__c = 'True';
dt= new Date();
dt.setDate(dt.getDate()+0);
Prospect__c.Converted_Date__c = dt;
var result = sforce.connection.update([ProspectObj]);
var status = "{!Prospect__c.Status__c}";
var newRecords = [];
{
var acct = new sforce.SObject("Account");
acct.OwnerId = '{!Prospect__c.OwnerId}';
acct.Name = '{!Prospect__c.Name}';
acct.ShippingStreet = '{!Prospect__c.Street__c}';
acct.ShippinggCity = '{!Prospect__c.City__c}';
acct.ShippingState = '{!Prospect__c.State__c }';
acct.ShippingPostalCode = '{!Prospect__c.Postcode__c}';
newRecords.push(acct);
}
var result = sforce.connection.create(newRecords);
var newRecords = [];
{
var opp = new sforce.SObject("Opportunity");
opp.AccountId = '{!Account.Id}';
opp.OwnerId = '{!Prospect__c.OwnerId}';
opp.Name = '{!Prospect__c.Description__c}';
opp.LeadSource = 'Converted from Prospect';
opp.StageName = 'Perception Analysis';
opp.Type = 'New Business';
opp.Prospect_First_Contact_Made__c = 'True';
opp.Prospect_Initial_Meeting_Scheduled__c = 'True';
opp.Prospect_Opportunity_Identified__c = 'True';
opp.Prospect_Requirements_Documented__c = 'True';
opp.Qualified_Need_to_Buy_Confirmed__c = 'True';
dt= new Date();
dt.setDate(dt.getDate()+30);
opp.CloseDate = dt;
newRecords.push(opp);
}
var result = sforce.connection.create(newRecords);
if (result[0].success == 'false') {
alert(result[0].errors.message);
} else {
window.parent.location = '/a05?fcf=00Bb0000003wFhp';
}
when I click the button I get an error saying that Prospect__c is not defined.
Any pointers would be a great help.
Thanks in Advance
Ronnie
I am trying to create a custom button on a custom Object that when clicked creates Account\Contact\Opportunity (like convert button on Lead).
The code I have is
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
var ProspectObj = new sforce.SObject("Prospect__c");
ProspectObj.ID = '{!Prospect__c.Id}';
ProspectObj.Converted__c = 'True';
dt= new Date();
dt.setDate(dt.getDate()+0);
Prospect__c.Converted_Date__c = dt;
var result = sforce.connection.update([ProspectObj]);
var status = "{!Prospect__c.Status__c}";
var newRecords = [];
{
var acct = new sforce.SObject("Account");
acct.OwnerId = '{!Prospect__c.OwnerId}';
acct.Name = '{!Prospect__c.Name}';
acct.ShippingStreet = '{!Prospect__c.Street__c}';
acct.ShippinggCity = '{!Prospect__c.City__c}';
acct.ShippingState = '{!Prospect__c.State__c }';
acct.ShippingPostalCode = '{!Prospect__c.Postcode__c}';
newRecords.push(acct);
}
var result = sforce.connection.create(newRecords);
var newRecords = [];
{
var opp = new sforce.SObject("Opportunity");
opp.AccountId = '{!Account.Id}';
opp.OwnerId = '{!Prospect__c.OwnerId}';
opp.Name = '{!Prospect__c.Description__c}';
opp.LeadSource = 'Converted from Prospect';
opp.StageName = 'Perception Analysis';
opp.Type = 'New Business';
opp.Prospect_First_Contact_Made__c = 'True';
opp.Prospect_Initial_Meeting_Scheduled__c = 'True';
opp.Prospect_Opportunity_Identified__c = 'True';
opp.Prospect_Requirements_Documented__c = 'True';
opp.Qualified_Need_to_Buy_Confirmed__c = 'True';
dt= new Date();
dt.setDate(dt.getDate()+30);
opp.CloseDate = dt;
newRecords.push(opp);
}
var result = sforce.connection.create(newRecords);
if (result[0].success == 'false') {
alert(result[0].errors.message);
} else {
window.parent.location = '/a05?fcf=00Bb0000003wFhp';
}
when I click the button I get an error saying that Prospect__c is not defined.
Any pointers would be a great help.
Thanks in Advance
Ronnie
Try changing this line:
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
All Answers
Try changing this line:
Regards.
Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
Thanks for all your help