You need to sign in to do that
Don't have an account?

Update a check box in a custom object using an S-control
subject says it all
I have a custom object, it has about 25 checkboxes. I want to update the selected checkboxes accorinding to pressing on a link.
How can I do it?
a more specific detail:
cb's 1,2,3,4,5 need to be selected if custom link 1 is pressed.
cb's4,5,6,7 need to be selected if custom link 2 is pressed (uncheck the rest)
Anyone?
try {
var updateObjects = new Array();
var obj = new Sforce.Dynabean("YourObjectName__c");
obj.set("Id", "{!YourObjectName_ID}");
obj.set("YourCheckboxFieldName__c", new Boolean(true));
updateObjects.push(obj);
var sr = sforceClient.Update(updateObjects)[0];
}
catch (ex) {
alert(ex);
}
Hi and thank you for your answer.
I did anter the text you have given me, but when pressing the link, all I got was that text in a window.
There must be some more I need to put in? how come I see the text and it's not doing what I want?
If the fields you are trying to update are checkboxes, the line of code that does this is either
obj.set(cb1name, new Boolean(true)); or
obj.set(cb1name, new Boolean(false));
where "cb1name" is the actual name of your checkbox field.
Make sure you replace "Your..." fieldnames ini the 3 lines below to match your actual object names. If this still doesn't work, post a code snippet so we can take a look...
var obj = new Sforce.Dynabean("YourObjectName__c");
obj.set("Id", "{!YourObjectName_ID}");
obj.set("YourCheckboxFieldName__c", new Boolean(true));
Message Edited by gsickal on 06-11-2006 09:27 AM
Message Edited by saariko on 06-12-2006 04:13 AM
Message Edited by saariko on 06-12-2006 04:13 AM
EUREKA !! :-)
Ok, phase 1 is complete. I am able to update the cb in a page, and reload it. Next request will be:
I want to have a custom link to clear (set to false) all of the cb's in the object (I have a bout 70). I am trying some for loop, but DOH. please see attached code, and if ne1 can advise, please:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<script
src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js"
type="text/javascript"></script>
<script type="text/javascript">
function initPage()
{
// alert(window.parent.parent.parent.location.href);
sforceClient.registerInitCallback(setupPage);
sforceClient.init("{!API_Session_ID}"," {!API_Partner_Server_URL_70}");
}
function setupPage( )
{
// alert("{!Boreg_ID}");
try {
var updateObjects = new Array();
var obj = new Sforce.Dynabean("Boreg__c");
obj.set("Id", "{!Boreg_ID}");
// This line will clear all settings
for (var k in obj.records) { obj.records[k].set(new Boolean,false); }
// for ( var x = 1 ; x < obj.get( ; x++ )
// {
// obj.set("X1__c", new Boolean(true));
// obj.set("X2__c", new Boolean(true));
// }
updateObjects.push(obj);
var sr = sforceClient.Update(updateObjects)[0];
refreshWindow();
}
catch (e) { alert(e); }
}
function refreshWindow(){
//alert("inside refreshWindow()");
//alert(window.parent.parent.parent.location.href);
try{
parent.parent.location.replace("/{!Boreg_ID}");
} catch (e) { alert(e); }
}
</script>
</head>
</html>
<body onload=initPage();>
<center>
<br><br><br>
<SPAN STYLE=" font-size: 75%; font-family: 'Arial', 'Helvetica', sans-serif;">
Updating item... Please Wait.
</span><br><br>
<img src="/img/waiting_dots.gif" alt="Please wait..." title="Please wait..." height="20" width="196">
</center>
</body>