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

How to get full string in the 'value' property of the button control and not only the first word
Please look at the 2 lines bellow and help me to understand why:
- value of the _name in first line = "Brett's Industrial Account"
- value of the _name in the second line = "Brett"
How to fix this one?
I will really appriciate your help.
============================================================
alert(_name);
output = "<input id=btn1 type=button name=btn1 onclick=\"" + fn + "\" value='" + _name + "'>";
+ escape(_name) +
The apostrophes around _name were the problem. If you use quotes instead, then the apostrophe in the middle of your value will be displayed.
Mike.
Thank you very much it worked.
Mike now I have the last ptoblem here if it's something quick I will really appriciate if you can help me:
I am trying to update the 'Account' object with the Primary_distributor__c(lookup field) and Primary_Distributor_Location__c and reload the page and I am getting the error:
{errors:{fields:'Primary_Distributor__c', message:'Primary Distributor: id value of incorrect type: test diane', statusCode:'MALFORMED_ID'}, id:null,success:'false',}
===MY CODE=======
function cm(_name,_street,_city,_state,_id) {
alert("You Selected: " + "'" + _name + "'" + " in " + _city + ", " + _state);
if (_name) {
var _IsMatch = new sforce.SObject("Account");
_IsMatch.Id = _id;
_IsMatch.Primary_Distributor__c = _name;
_IsMatch.Primary_Distributor_Location__c = _city + ", " + _state;
//_IsMatch.BillingState = _state;
var updateIsMatch = sforce.connection.update([_IsMatch]); //actually perform update
if (updateIsMatch[0].getBoolean("success")) { //if successful update of existing record
alert("Successfully updated contact name!"); //indicate that the update was successful
window.opener.location.reload();
} else {
alert("Error:\n"+updateIsMatch[0]); //display the error
}
}
}
"Select ID from Primary_Distributor__c where name = '"+_name+"'
Mike,
There is no custom object - 'Primary_Distributor__c' is in the account object but the 'RecordTypeId=012600000004w6TAAQ'
The screen I am trying to update also Account object but the 'RecordTypeId=012600000004w6UAAQ'
Then...
Code:
Mike,
Here is the first qrdr that works for me:
================================
var qrdr = sforce.connection.query("select Id, Name, BillingStreet, BillingCity, BillingState from Account where RecordTypeId='012600000004w6TAAQ' and Name like '" + tt + "%' and BillingState='" + s + "'");
================================
so, the 'Id' is available for me:
===============================
var fn = "cm(";
fn += ((_name && _name != null) ? "'" + _name + "'" : null) + ",";
fn += ((_street && _street != null) ? "'" + _street + "'" : null) + ",";
fn += ((_city && _city != null) ? "'" + _city + "'" : null) + ",";
fn += ((_state && _state != null) ? "'" + _state + "'" : null) + ",";
fn += "'" + _id + "');";
output = "<input id=btn1 type=button name=btn1 onclick=\"JavaScript:" + fn + "\" value=\"" + _name + "\">";
html += output;
==============================
when the button clicked all values passed to cm function: Please note I've got the Primary_Distributor_Location__c field working but getting the error to do the _IsMatch.Primary_Distributor__c = _name; because it's a reference field still to the 'Account' object
=====================================
function cm(_name,_street,_city,_state,_id) {
alert("You Selected: " + "'" + _name + "'" + " in " + _city + ", " + _state);
str_id='{!Account.Id}';
if (_name) {
var _IsMatch = new sforce.SObject("Account");
_IsMatch.Id = str_id;
_IsMatch.Primary_Distributor__c = _name;
_IsMatch.Primary_Distributor_Location__c = _city + ", " + _state;
var updateIsMatch = sforce.connection.update([_IsMatch]); //actually perform update
if (updateIsMatch[0].getBoolean("success")) { //if successful update of existing record
alert("Successfully updated!"); //indicate that the update was successful
window.close();
window.opener.location.reload();
} else {
alert("Error:\n"+updateIsMatch[0]); //display the error
}
}
}
=================================
ERROR:
{errors:{fields:'Primary_Distributor__c', message:'Primary Distributor: id value of incorrect type: test diane', statusCode:'MALFORMED_ID'}, id:null,success:'false',}
Code: