You need to sign in to do that
Don't have an account?
ssurfer
Java or HTML code.... which way to go and why?
For about a week i've been trying to solve a problem with pre-populating a record of a custom object linked to an opportunity. Following the information i've gotten from helpful people here and what i've read, i can see that the solution could be one of two: either i build a java s-control or i build out an HTML code. My question here is what to choose when and why?
I have pasted in the two solutions (the java version still not functionning and in it's most basic format, that in theory should only open up the custom object)
My impression is that the HTML way is a "cheat" and the Java is the "real" way to go, especially having Apex in mind. Could anyone please enlighten me?
Best regards,
Johan
/setup/ui/recordtypeselect.jsp?retURL=
%2{!Opportunity.Id}&save_new_url=%2Fa0J%2Fe%3FretURL
%3D%25{!Opportunity.AccountId}%26CF00N2000000129Zf
%3D{!Opportunity.Account}%26CF00N2000000129Zf_lkid
%3D{!Opportunity.AccountId}%2600N2000000129Zk
%3D{!Opportunity.Survey_Address__c}%2600N200000012ANk
%3D{!Opportunity.Pack_Date_1__c}&ent=01I200000004VkE
++++++++++++++++
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="/soap/ajax/8.0/connection.js" type="text/javascript"></script>
<script language="javascript">
<script>
function setupPage() {
createWork_Order();
}
function createWork_Order() {
var wo = new sforce.SObject("Work_Order__c");
}
try {
saveResult = sforce.connection.create([wo]);
}catch(error) {
alert("got an error: " + error);
}
if (result[0].getBoolean("success")) {
alert("new Work Order created with id " + result[0].id);
} else {
alert("failed to create Work Order " + result[0]);
}
</script>
</head>
<body onload="setupPage();"></body>
</html>
<html>
<head>
<script src="/soap/ajax/8.0/connection.js" type="text/javascript"></script>
<script language="javascript">
<script>
function setupPage() {
createWork_Order();
}
function createWork_Order() {
var wo = new sforce.SObject("Work_Order__c");
}
try {
saveResult = sforce.connection.create([wo]);
}catch(error) {
alert("got an error: " + error);
}
if (result[0].getBoolean("success")) {
alert("new Work Order created with id " + result[0].id);
} else {
alert("failed to create Work Order " + result[0]);
}
</script>
</head>
<body onload="setupPage();"></body>
</html>
Thank you Greg,
I've modified the code a bit and now it works and looks like this:
Code:
I'm still trying to solve it with a java script though, but as a temporary solutions this works ok. It also seems to bypass the record type selection so i've made the record type available for change on the Work_Order object.
I found that the Mozilla Firebug was extremely useful when finding the fields in the code. Basically it lets me just mark a field on any object, right-click and choose inspect and it will give me the ID (like 00N2000000023QPd) of that specific object. It makes it very much faster to write this thing.