- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2023 10:16 PM
Hi All,
I have 2 tables user table & personal data table. Personal email id available in personal data table available. Now i need to update personal email id in user table. In both tables employee id available based employee id i need to update personal email in user table. How we can achieve this..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2023 10:43 PM - edited 07-07-2023 11:00 PM
Hi @Dasari Srihari,
You need to create after insert/update business rule on personal data table. Below shared the sample scripts, modify it accordingly.
Sample scripts:
var user_record = new GlideRecord('sys_user');
user_record.addQuery('employee_id', current.employee_id_column_name); // current: object for personal data table
user_record.query();
if (user_record.next()) {
user_record.personal_email_id = current.personal_email_id_column_name.toString();
user_record.setWorkflow(false); // disables the other business rules
user_record.autoSysFields(false); // used to disable the update of 'sys' fields (Updated, Created, etc.) for a particular update
user_record.update();
}
Please mark as helpful and correct, if I have been able to assist you in any way!
This will be useful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 01:06 AM
Hi @Dasari Srihari,
Scripts looks good to me. Make sure that field names are correct.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 09:49 AM
Hi @Dasari Srihari,
Great!. Yes, you need to execute same scripts to update existing records.
Please mark as helpful and correct, if I have been able to assist you in any way!
This will be useful for future readers.
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 12:49 PM
@Dasari Srihari wrote:Hi All,
I have 2 tables user table & personal data table. Personal email id available in personal data table available. Now i need to update personal email id in user table. In both tables employee id available based employee id i need to update personal email in user table. How we can achieve this..
To update fields using another table, you can utilize SQL's UPDATE statement with a JOIN operation. The specific syntax may vary slightly depending on the database management system you are using, but the general steps are as follows:
Understand the relationship: Identify the relationship between the two tables that will allow you to update the fields. Typically, there should be a common column between the tables that can be used to establish the relationship.
Write the UPDATE statement: Construct an UPDATE statement with a JOIN operation to update the desired fields. The syntax may look like this:
In this example, table1 is the table you want to update, table2 is the table containing the new values, and common_column is the column that establishes the relationship between the two tables. field1 is the field in table1 that you want to update, and field2 is the corresponding field in table2 with the new values. You can also add a condition in the WHERE clause to further filter the rows to be updated if needed.
- Execute the UPDATE statement: Run the SQL query to execute the UPDATE operation. This will update the specified fields in table1 using the corresponding values from table2 based on the established relationship.
Please note that the specific syntax and capabilities may vary depending on the database management system you are using. Consult the documentation or resources specific to your database for more details on the correct syntax and options available to you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2025 04:03 PM - edited 03-16-2025 09:31 AM
I had the same requirement which was to update fields on the project form based on a change made to a field on the demand form.
When a demand user or manager updates a field on the demand record then this update data should roll up to the project form fields.
To achieve this I created:
Business Rule
Table: dmn_demand
When: after
Order: 100
Insert: checked
Update: checked
Add your specific filter conditions - here I have used sys_id != empty
On the Advanced tab I have created the below script: