• KD Teja
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
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:

{!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
 
Hello Everyone,

I have created a formual field on a custom object and the return value is text to display an image from static resources.
This scenario should display an image based on a lookup field value after saving a record.
1. Product__c field has a master-detail relationship with other custom_object.

The code i have written for formula:
==============================
IF
(Product__c="SPRO-0003",
IMAGE('/resource/i7', 'iPhone7',120,200),
IF
(Product__c="SPRO-0004",
IMAGE('/resource/s8', 'Samsung S8', 120,200),
IF
(Product__c="SPRO-0005",
IMAGE('/resource/i8', 'iPhone8', 120,200),
'Product Image Not Available')
)
)
===============================

Here it is giving me that only the last false condition (i.e., "Product Image Not Available") as a result after saving a record.
Please help me to get this solved.

Thanks in Advance,
Teja
Hello Everyone,

Please help me out from creating a new row in custom object whenever a new contact created in contact object.

1.I have a custom date field in contact object
2.I shouldn't have any relationship with new contact->custom object.
3.Whenever i create new contact with some date it should create a row with "contact name" and "date"
4.Whenever i change Date on an existing contact it should create another row with diff date in custom object.
5.I have a lookup field in custom object with Account Object.

Plesae help how to make this work using triggers

Thanks in Advance.
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:

{!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
 
Hello Everyone,

Please help me out from creating a new row in custom object whenever a new contact created in contact object.

1.I have a custom date field in contact object
2.I shouldn't have any relationship with new contact->custom object.
3.Whenever i create new contact with some date it should create a row with "contact name" and "date"
4.Whenever i change Date on an existing contact it should create another row with diff date in custom object.
5.I have a lookup field in custom object with Account Object.

Plesae help how to make this work using triggers

Thanks in Advance.