• tjateurotire
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Because of the constraints around using picklist values in formulas (ie. only CASE and ISPICKVAL are available) I found a solution which takes a picklist value and returns that value as text in another field. Or at least this is what the post claims this code is supposed to do. I can not get this thing to work however, and was wondering if the code is still valid. When I place the s-control on the page layout, it is certainly there... and when I go to s-control dependencies it shows that the s-control is dependent on the picklist field, but it does not copy the picklist value to the other custom field (which by the way I have created as a standard text field). Am I missing something? Is this code still valid?

Below is a direct copy/paste from salesforce.

This can be used for long picklists, or picklist that are often changed. It allows to bring the text value of a picklist into a custom field.

Object on which the control is applied:  "Target__c"

Name of the picklist field: "Mill_1_Style__c"

Name of the field on which we copy the value from Mill_1_Style__c: "Right__c"

 

S-Control:

<html>
<head>
<link href="/sCSS/8.0/1171411121000/Theme2/default/common.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<script src="/soap/ajax/8.0/connection.js"></script>
<script>
var FieldLabelofFieldToUpdate = "Right";
function initPage() {
var tarx= new sforce.SObject("Target__c");
tarx.Id="{!Target__c.Id}";

newAmt= "{!Target__c.Mill_1_Style__c}"

resultGo = sforce.connection.update([tarx]);
setTDInnerHTML(newAmt);
document.body.innerHTML = "";
}
function setTDInnerHTML(val)
{
var d = window.parent.document;
var tds = d.getElementsByTagName("TD");
for(var i=0; i<tds.length; i++)
{
if(tds[i].innerHTML == FieldLabelofFieldToUpdate )
{
tds[i].nextSibling.innerHTML = val;
}
}
}
</script>
</head>
<body bgcolor="#F3F3EC" onload="initPage();">
</body>
</html>


Because of the constraints around using picklist values in formulas (ie. only CASE and ISPICKVAL are available) I found a solution which takes a picklist value and returns that value as text in another field. Or at least this is what the post claims this code is supposed to do. I can not get this thing to work however, and was wondering if the code is still valid. When I place the s-control on the page layout, it is certainly there... and when I go to s-control dependencies it shows that the s-control is dependent on the picklist field, but it does not copy the picklist value to the other custom field (which by the way I have created as a standard text field). Am I missing something? Is this code still valid?

Below is a direct copy/paste from salesforce.

This can be used for long picklists, or picklist that are often changed. It allows to bring the text value of a picklist into a custom field.

Object on which the control is applied:  "Target__c"

Name of the picklist field: "Mill_1_Style__c"

Name of the field on which we copy the value from Mill_1_Style__c: "Right__c"

 

S-Control:

<html>
<head>
<link href="/sCSS/8.0/1171411121000/Theme2/default/common.css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" type="text/css" />
<script src="/soap/ajax/8.0/connection.js"></script>
<script>
var FieldLabelofFieldToUpdate = "Right";
function initPage() {
var tarx= new sforce.SObject("Target__c");
tarx.Id="{!Target__c.Id}";

newAmt= "{!Target__c.Mill_1_Style__c}"

resultGo = sforce.connection.update([tarx]);
setTDInnerHTML(newAmt);
document.body.innerHTML = "";
}
function setTDInnerHTML(val)
{
var d = window.parent.document;
var tds = d.getElementsByTagName("TD");
for(var i=0; i<tds.length; i++)
{
if(tds[i].innerHTML == FieldLabelofFieldToUpdate )
{
tds[i].nextSibling.innerHTML = val;
}
}
}
</script>
</head>
<body bgcolor="#F3F3EC" onload="initPage();">
</body>
</html>