using sql for a field that references that states ...
# ask-stanley-ai
m
using sql for a field that references that states records, is it possible to pull in the shortname of the state instead of the ID?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that it is possible to pull in the short name of the state instead of the ID using SuiteQL or the search API in SuiteScript. Here is a sample SuiteScript code that was shared in the conversation:
Copy code
javascript
srch = search.create({
	type : "state",
	filters : [
		["country","anyof","US"]
	],
	columns : [
		search.createColumn({
			name: "id",
			sort: search.Sort.ASC
		}),
		"fullname",
		"shortname",
		"country",
		"inactive"
	]
});
res = srch.run().getRange(0,1000).map(r => r.getAllValues())
This script creates a search on the "state" type, filters for states in the US, and retrieves the columns "id", "fullname", "shortname", "country", and "inactive". The results are then mapped to their respective values. Please note that the
search.Type.STATE
is used to access the state records. The
shortname
field should give you the abbreviated name of the state. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.854433
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.835115075
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823583603
Please provide your feedback on this answer.