You need to sign in to do that
Don't have an account?
Clone in an SQL Statement gives error
The following code worked last week!
It clones the first record of a related object. I keep it on a button.
Has anything chenged in Salesforce over the weekend?
The code:
{!REQUIRESCRIPT("/soap/ajax/21.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/21.0/apex.js")}
var a = {!Location__c.Name}
var result = sforce.connection.query("SELECT SessionIDs__c FROM Promo_Material_Snapshot__c"+
" WHERE Location_ID__c = '"+ a +"' limit 1")
// var result = sforce.connection.query("SELECT SessionIDs__c FROM Promo_Material_Snapshot__c limit 1")
var records = result.getArray("records")
var IdsToClone = String(records[0]).substring(60, 75)
window.open("/"+IdsToClone +"/e?clone=1&retURL=/"+IdsToClone )
Now it gives the following error:
faultcode: MALFOREMED QUERY..
...
no viable alternative at character...
Last Week it Worked Fine!
Any ideas / Suggestions?
All the best,
Stefanos
Not too sure if this will work but try putting your SOQL in single quotes intead of double and also where you have the single quotes in the Where clause escape the single quotes with a forward slash.
eg:
var result = sforce.connection.query('SELECT SessionIDs__c FROM Promo_Material_Snapshot__c "+
" WHERE Location_ID__c = \'"+ a +"\' limit 1')