You can directly get the ID from the event object if you've set a record number as the key field.
Yes, I can.
However, I have set the "title" field (not the Record number) as the Lookup field's key field.
Let me ask a question.
Question 1: Getting the second record
How do I ensure I get the correct record if there are two records with the same title (in the title field)?
What if the query results in the first record, but I want the second record?
How can I solve this?
Also, I have another question.
Question 2: Why am I unable to get the Record Number directly?
By hovering over the Lookup field from the "Lookup Picker" window, I can see that text is hyperlinked to the record, which includes the Record Number (as shown below).
But then why am I unable to get the Record Number directly with something like this?
You will need to include the data obtained thru the Lookup field as a key to specify which record.
And about the 2nd question, I’m not quite sure what the problem is, but I assume your question is why the record number differs from the URL in the lookup field. Please correct me if I’m wrong.
“233” is the record number of that record in the app.
The record number you see in the URL is the record number of the record that the lookup field references.
In other words, they are completely different records.
Let’s say; for example, there is a field that can be duplicated; on my test app, I used the lookup field to lookup a product name and also a text field that displays a size.
When trying to look up, the same product name is displayed.
It would be impractical to determine which records to look up based solely on the duplicable fields.
Therefore, if the field is duplicable, the “size” (information obtained in the lookup) can also be included in the query when retrieving records to identify the record.
I hope this explains what Chris mentioned previously.
Hi @Sean_Tcbn
Thank you . I understand what you mean.
But I just wanted to get the record id like this. kintone.app.record.get().record["lookup"].xxx
If it is possible, could please explain about why I can’t get the record id like getting the App Id.
Regards.
Hello @unudeveloper
This is impossible because this API does not obtain the whole data of the other record grabbed by a lookup field. It only grabs data that is specified in the lookup field settings.
You can see this by looking at the response of the API:
var record = kintone.app.record.get();
console.log(record);
And there’s no API like App ID that precisely does it as of now.
Hi @Chris
Thanks for your response.
I also tried to get the record id using kintone.app.record.get() but unfortunately it returned "Lookup": { "type": "SINGLE_LINE_TEXT", "value": "Document Title" }.
It is same as Text field.