You need to sign in to do that
Don't have an account?
IZavalun
Help to pass the parramentr to the function
Hello - Please help to fix my syntax problem here to pass the parametr, I need to get the contact in function cm(contact)...
Please see in red:
==============================================
<html>
<head>
<script src="/soap/ajax/9.0/connection.js"></script>
<script src="Link: " type="text/javascript"></script>
<script language="javascript">
var fn = "cm(this)";
function do_code()
{
//////////////////////////////////////
var cust_name = '{!Account.Name}';
var qrdr5 = sforce.connection.query("Select c.Id from Account c where c.Name= '" + cust_name + "'");
var records = qrdr5.getArray("records");
for (var x = 0; x < records.length; x++)
{
tt5 = records[x];
var ttt = tt5.get("Id");
}
/////////////////////////////////////
var qrdr2 = sforce.connection.query("Select Name from Contact c where AccountId= '" + ttt + "'order by createdDate");
var records = qrdr2.getArray("records");
document.write("<b><u>Please Select Customer Contact:</u></b><BR><BR>");
document.write("<HR>");
for (var y = 0; y < records.length; y++)
{
tt2 = records[y];
var t=tt2.get("Name");
document.write("<BR>");
output = "<input id=btn1 type=button name=btn1 onclick=cm(obj); value='" + t + "'>";
document.write(output);
document.write("<BR>");
}
document.write("<BR>");
document.write("<HR>");
}
////////////////////////////////////
function cm(contact) {
alert(contact);
}
<head>
<script src="/soap/ajax/9.0/connection.js"></script>
<script src="Link: " type="text/javascript"></script>
<script language="javascript">
var fn = "cm(this)";
function do_code()
{
//////////////////////////////////////
var cust_name = '{!Account.Name}';
var qrdr5 = sforce.connection.query("Select c.Id from Account c where c.Name= '" + cust_name + "'");
var records = qrdr5.getArray("records");
for (var x = 0; x < records.length; x++)
{
tt5 = records[x];
var ttt = tt5.get("Id");
}
/////////////////////////////////////
var qrdr2 = sforce.connection.query("Select Name from Contact c where AccountId= '" + ttt + "'order by createdDate");
var records = qrdr2.getArray("records");
document.write("<b><u>Please Select Customer Contact:</u></b><BR><BR>");
document.write("<HR>");
for (var y = 0; y < records.length; y++)
{
tt2 = records[y];
var t=tt2.get("Name");
document.write("<BR>");
output = "<input id=btn1 type=button name=btn1 onclick=cm(obj); value='" + t + "'>";
document.write(output);
document.write("<BR>");
}
document.write("<BR>");
document.write("<HR>");
}
////////////////////////////////////
function cm(contact) {
alert(contact);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Customer Contacts...</title>
</head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Customer Contacts...</title>
</head>
<body onLoad="do_code();">
</body>
</html>
</body>
</html>
Since you were using the {!Account.Name} parameter in your original code, I figure you are accessing this sControl from the Account object. If this is not the case then this code may not work for you.
Code:
Sorry to rewrite so much of your original work but I couldn't follow it. So copy and paste this code in a new sControl and let me know if this doesn't assist you with the issue you've been encountering.
-greg
Hi Greg,
I did override my code with your code and it works same way it did for me but….
update IS_Mach
set CustomerContact=btnValue (passed to the function)
WHERE AccountId='{!Account.Id}
I will really appreciate if you will help me with this syntax
Try this:
Code:
This will allow you to send the contact name to the function cm() when each button is clicked. You can do whatever you want in that function as all I did was alert that the name was passed.
-greg
Greg,
I am having same problem now the message box doesn't appear with the ContactName.
Any idea?
GREG - it works. Thanks.
The last thing I want to acomplish here is to use the update (red line). Would you please give me an idea how in salesforce I can do it.
I really appriciate your help.
========================================================
//handles click from above buttons
function cm(contactName) {
alert(contactName);
alert('{!IS_Mach__c.Name}');
update IS_Mach__c set Customer_contact__c= 'contactName' where Name='{!IS_Mach__c.Name}'
}
This should work but depending on how this sControl is being accessed, it may not. My primary concern is that the {!IS_Mach__c.Id} value may not be available. If it is not then you could query for that value based on the {!IS_Mach__c.Name} value stored in your custom object prior to actually making the update.