• RLStallard-GXT
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

Greetings folks,

I've been banging my head, searching all over SFDC user/developer sites and googled, but still can't find solution. I have read in these forums of others doing this, but they do not post the complete code of how it's done. I am xhtml/css savvy but am a total newbie at JavaScript (except cut 'n' paste) and S-Controls (this is my first attempt).


DESCRIPTION
---------------------------------------------------
This is what I am attempting to do:

[]  Create a new record of a Custom Object (Quote/Sales Order) via a custom link on Opportunities that calls an S-Control.
[]  The custom object is a related list (child) to opportunities.)
[]  When the link is clicked, the S-Control will open the input form page of a new record of the custom object with certain fields prepopulated.
[]  These fields are prepopulated with data contained in fields of the related Opportunity and Account.
[]  The input page with the prepopulated is to remain open so that the user may complete any remaining fields he/she wishes and then saves the new record.


PURPOSE
---------------------------------------------------
This custom object has fields containing the exact same data as fields in the related Opportunity and Account. Thus the purpose of the S-Control is to improve usability and data integrity by eliminating the need to force users to perform double transcription.


CODE
---------------------------------------------------
Here is the code I wrote with comments on field types and alert results. It doesn't create the new record and returns the saveAlert ID as null.


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Create Quote</title>

<script language="javascript" src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script language="javascript">
<!--
function initPage() {
sforceClient.registerInitCallback(createQuote);
sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");
window.setTimeout(";", 1000);
}

function createQuote() {
var quote = new Sforce.Dynabean("Quote_Sales_Order_Data__c");
alert("function initPage() and start of createQuote() running good!") // Alert displays
quote.set("Name", "{!Opportunity_Opportunity_Number}") //Standard text field - Name of custom objext - Required - Reading from Autonumber field
quote.set("Opportunity__c", "{!Opportunity_Name}") //Master-Detail relationship - Parent Opportunity - Required
quote.set("GXT_Business_Unit__c", "{!Opportunity_GXT_Business_Unit}");
quote.set("GXT_Service_Center__c", "{!Opportunity_GXT_Service_Center}");
quote.set("Submission_Date__c", new Date());
quote.set("Survey_Name_Area_Block__c", "{!Opportunity_Survey_Name_Area_Block}");
quote.set("GXT_Project_Manager__c", "{!Opportunity_GXT_Project_Manager}");
quote.set("Geographic_Region__c", "{!Opportunity_Geographic_Region}");
quote.set("Environment__c", "{!Opportunity_Environment}");
quote.set("Country__c", "{!Opportunity_Country}");
quote.set("Dimension__c", "{!Opportunity_Dimension}");
quote.set("Expected_Start_Date__c", new Date("{!Opportunity_Expected_Start_Date}"));
quote.set("Expected_Delivery_Date__c", new Date("{!Opportunity_Expected_Delivery_Date}"));
quote.set("Account__c", "{!Account_Name}");
quote.set("Billing_Address__c", "{!Account_BillingAddress}");
alert("All quote.set items completed!") // Alert displays

var saveResult = sforceClient.create([quote]);
alert("New Quote Item ID: " + saveResult[0].id); // Alert returns null

}
//-->
</script>
</head>

<body onload="initPage()">
<p>This feature is still under development and not yet implemented. Please click your browsers Back button to return to your opportunity. Sorry for the inconveniene.</p>
</body>
</html> 
---------------------------------------------------

I appreciate any guidance you can offer. My users are very annoyed at having to do double entry, causing SFDC adoption to decline significantly in my organization.


Thanks and may you have a great day, everyday!

Robert
rstallard@gxt.com

Message Edited by RLStallard-GXT on 10-19-2006 12:59 AM


Greetings folks,

I've been banging my head, searching all over SFDC user/developer sites and googled, but still can't find solution. I have read in these forums of others doing this, but they do not post the complete code of how it's done. I am xhtml/css savvy but am a total newbie at JavaScript (except cut 'n' paste) and S-Controls (this is my first attempt).


DESCRIPTION
---------------------------------------------------
This is what I am attempting to do:

[]  Create a new record of a Custom Object (Quote/Sales Order) via a custom link on Opportunities that calls an S-Control.
[]  The custom object is a related list (child) to opportunities.)
[]  When the link is clicked, the S-Control will open the input form page of a new record of the custom object with certain fields prepopulated.
[]  These fields are prepopulated with data contained in fields of the related Opportunity and Account.
[]  The input page with the prepopulated is to remain open so that the user may complete any remaining fields he/she wishes and then saves the new record.


PURPOSE
---------------------------------------------------
This custom object has fields containing the exact same data as fields in the related Opportunity and Account. Thus the purpose of the S-Control is to improve usability and data integrity by eliminating the need to force users to perform double transcription.


CODE
---------------------------------------------------
Here is the code I wrote with comments on field types and alert results. It doesn't create the new record and returns the saveAlert ID as null.


Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>Create Quote</title>

<script language="javascript" src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>
<script language="javascript">
<!--
function initPage() {
sforceClient.registerInitCallback(createQuote);
sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");
window.setTimeout(";", 1000);
}

function createQuote() {
var quote = new Sforce.Dynabean("Quote_Sales_Order_Data__c");
alert("function initPage() and start of createQuote() running good!") // Alert displays
quote.set("Name", "{!Opportunity_Opportunity_Number}") //Standard text field - Name of custom objext - Required - Reading from Autonumber field
quote.set("Opportunity__c", "{!Opportunity_Name}") //Master-Detail relationship - Parent Opportunity - Required
quote.set("GXT_Business_Unit__c", "{!Opportunity_GXT_Business_Unit}");
quote.set("GXT_Service_Center__c", "{!Opportunity_GXT_Service_Center}");
quote.set("Submission_Date__c", new Date());
quote.set("Survey_Name_Area_Block__c", "{!Opportunity_Survey_Name_Area_Block}");
quote.set("GXT_Project_Manager__c", "{!Opportunity_GXT_Project_Manager}");
quote.set("Geographic_Region__c", "{!Opportunity_Geographic_Region}");
quote.set("Environment__c", "{!Opportunity_Environment}");
quote.set("Country__c", "{!Opportunity_Country}");
quote.set("Dimension__c", "{!Opportunity_Dimension}");
quote.set("Expected_Start_Date__c", new Date("{!Opportunity_Expected_Start_Date}"));
quote.set("Expected_Delivery_Date__c", new Date("{!Opportunity_Expected_Delivery_Date}"));
quote.set("Account__c", "{!Account_Name}");
quote.set("Billing_Address__c", "{!Account_BillingAddress}");
alert("All quote.set items completed!") // Alert displays

var saveResult = sforceClient.create([quote]);
alert("New Quote Item ID: " + saveResult[0].id); // Alert returns null

}
//-->
</script>
</head>

<body onload="initPage()">
<p>This feature is still under development and not yet implemented. Please click your browsers Back button to return to your opportunity. Sorry for the inconveniene.</p>
</body>
</html> 
---------------------------------------------------

I appreciate any guidance you can offer. My users are very annoyed at having to do double entry, causing SFDC adoption to decline significantly in my organization.


Thanks and may you have a great day, everyday!

Robert
rstallard@gxt.com

Message Edited by RLStallard-GXT on 10-19-2006 12:59 AM

We have written a number of Scontrols that prefill data from the current object to a new object.  We are now trying to prefill data into a new object pulling data from the current object and from another object with a relationship to the current one.

For example, custom object 'Operations Response' contains a field - 'Case' that is a lookup field to the Case object -- Lookup(Case).  I want to pull a couple of fields from this Case object and copy the data into the new object I am creating through a weblink. 

Finally, I am looking to populate additional data from yet another custom object (HR Link) that has a Master (Case) - Detail (HR Link) relationship with Case

Since I am new to the AppExchange API and am a Javascript novice, I am hoping for some help with sample code showing the required navigation using a series of Retrieve or Query functions.

Many thanks in advance. 

Message Edited by TransitForce on 09-12-2006 12:15 PM

Message Edited by TransitForce on 09-13-2006 03:48 PM