You need to sign in to do that
Don't have an account?
Detail page custom button ..
I am not getting a proper ID
!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
var newRecords = [];
var c = new sforce.SObject("Leave_Balance__c");
result1 = sforce.connection.query("Select Id from Leave_Balance__c where Employee_Name__c= '{!Leave_Application__c.OwnerId}' and LeaveType__c='{!Leave_Application__c.LeaveType__c}' limit 1");
// LeaveType__c is a reference { look up } to another object.... but it's giving some error , but it works fine in SOQL query in apex ??
records = result1.getArray("records");
if (records.length == 1) {
var record = records[0];
Id = (record.id);
alert(id);
// here my id is some ext-gen1 ??
} else {
alert("Something went wrong here");
}
Hi Rahul,
Even i was using record as a variable.
I was generation two alert boxes record.employee_name__c and record.id
record.employee_name__c is providing correct value { an ID as it is a reference field }
but record.id is giving ext -gen1
I also changed the variable name as u suggested, But still facing the same issue ...
Problem is with this piece of code:
Change it to:
Even if you alert : alert(id); it will display ext -gen1(id might be a global variable holding ext -gen1).
ID is not an global variable. I am fetching it from a saleforce record of LEAVE_BALANCE__C.
it must be 15 digit ID as its retruning value in the SOQL query exectuion.
id retrieves HTML Id in your DOM, so change the variable name which you are using to collect id.
Try this:
Hi Rahul,
I already tried that , but no luck
But I have found the solution. When i Retrieve the NAME of the record. It is giving me back the RECORD ID
I can solve that my problem using that, But 'm not satisfied that why is that happening.