how to populate data dynamically into choice list which belongs to 2 tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 11:52 PM
Hello Everyone,
I am trying to populate data into choice field from the table and i have no idea how to do this.
My issue is:
I would want to select the typer of share and when i click on file share in the second choice list i would want to populate the file path.(As shown in pic 1)
The issue here is i am using a custom table(pic 2) to save the file share information and the fields are on incident table.
Is there a way i can map these tables?
Or do i write a client script or use AJAX i have no idea.
Please guide me .
- Labels:
-
Discovery
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2021 06:11 AM
This tells me the Client Script is probably OK - since it is adding the None option - unless that was already there before. We could add some gs.addInfoMessage lines to the Script Include so that you can see that the script include is running, and then key points along the way so that you can see the sysparm_filetype value passed from the client, and if the GlideRecord query returns results, etc. But first, I can see that the actual name of the table
u_file_autorization
does not match the name used in the GlideRecord
u_file_authorization
Also, the field name updates to the optionsArray.push block should look more like this - sorry my comment wasn't clear
optionsArray.push({
'label' : fa.u_filetype.toString(),
'value' : fa.u_filetype.toString()
});
Assuming that u_filetype is the field name that contains the string value that you want to see in the drop down choices. I don't see that field name in your partial table screen shot, so change this if needed. The same value is repeated here for flexibility in using this code elsewhere. When you setValue of a choice list you need to supply a label and value. If they're the same you can just pass the same value twice, but this code allows to get labels from one field and values from another, such as is used on the sys_choice table. I'm also assuming the u_sharetype field contains the same value as the value for the choice list options on the Select the file type field on the incident table. or else the query won't find any matching records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 09:09 AM
Many thanks for your script. For a similar need, I have used this script.
In order to make it work, I had to remove this line in Script Include:
fa.addQuery('u_share_type', this.getParameter('sysparm_fileType'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2023 09:35 AM
.