Assigning value to a field based on another table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 03:47 AM
Hi,
I'm battling with this business rule and would appreciate your assistance. New to scripting world!
We have a requirement to assign value to a field based on another table. Let me explain you clearly........... We have 2 tables sys_user table (base table) and organization data (custom table), both contains the user information. Both the tables contains a field called organization unit (custom field), which is a reference to some "X" table. Now the task is we have to populate this field organization unit on sys_user table based on organization data table.
Thanks in advance.........
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 04:00 AM
You can do it with a calculation script on the field from sys_user table.
Here is a thread that might give you some ideas:
Calculated field vs Client script to populate field based on other field values
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 04:06 AM
Hi Sergiu,
Thanks for reply. Here in my case I have to populate a field based on value of another table. So I think we have to use Business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 04:17 AM
You can still use GlideRecord in calculated fields.
For example, on my own instance I created a field called "myField" in incident table and added a calculation like this (just an example, adapt to your requirements):
var gr = new GlideRecord('task');
gr.addActiveQuery();
gr.setLimit(1);
gr.query();
while(gr.next()){
current.myfield = gr.number;
}
After I added the new field on incident form, just looking at an incident I see the value is populated. The XML shows:
<myfield>CHGPHASE0030001</myfield>
So, you can use GlideRecord for this:
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2015 04:37 AM
Thanks Sergiu