You need to sign in to do that
Don't have an account?
DharmaTeja K
Create a record on Custom Object using onClick of javascript Button
Hello All,
Please help me to create a record on Custom Object using javascript button.
1. Whenever i click a button it should pick (accountid,ownerid,CloseDate) from Opportunity record
2. It should create a record with above fields on Custom Object.
===================================================
> The below code that i have written is throwing an error on chrome browser
(faultstring:'soapenv:Client',faultstring:''NaN-NaN-NaNTNaN:NaN:NaN:NaN-NaN:NaN' is not a valid value for the type xsd:date',)
> When i try this in IE it is giving me some other date in internet explorer
> I have tried so many things (parsing,format,toISOString,toLocaleDate..etc..,) but no luck.
===================================================
Code:
Please correct me what is the wrong with my code. Every field is populating except closeDate field.
Thanks in Advance,
Teja
Please help me to create a record on Custom Object using javascript button.
1. Whenever i click a button it should pick (accountid,ownerid,CloseDate) from Opportunity record
2. It should create a record with above fields on Custom Object.
===================================================
> The below code that i have written is throwing an error on chrome browser
(faultstring:'soapenv:Client',faultstring:''NaN-NaN-NaNTNaN:NaN:NaN:NaN-NaN:NaN' is not a valid value for the type xsd:date',)
> When i try this in IE it is giving me some other date in internet explorer
> I have tried so many things (parsing,format,toISOString,toLocaleDate..etc..,) but no luck.
===================================================
Code:
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} var opp = new sforce.SObject("Opportunity"); opp.Account = "{!Opportunity.AccountId}"; opp.OwnerId = "{!Opportunity.OwnerId}"; opp.CloseDate = "{!Opportunity.CloseDate}"; alert(opp.CloseDate); var ord = new sforce.SObject("Order__c"); ord.Account_Name__c = opp.Account; ord.Account_Director_Name__c = opp.OwnerId; if(opp.CloseDate==null || opp.CloseDate == ''){ ord.Customer_Signature_date__c = null; } else { var temp = new Date(opp.CloseDate); ord.Customer_Signature_date__c = temp; } new_rec = sforce.connection.create([ord]); alert('Opportunity Converted successfully ID : '+new_rec[0].id);======================================================
Please correct me what is the wrong with my code. Every field is populating except closeDate field.
Thanks in Advance,
Teja
Code snippet seems to be good. Can you make sure the date field is mapped to date field (DateTime field would mismatch here).
Thanks for your reply, i have cross checked again below screenshot is from opportunity object
and i've been mapping above field to below custom object field "Customer_Signature_date__c"
Thanks.