- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 12:13 PM
We are decommissioning a second domain and transferring all those accounts to new accounts in our primary domain. I am being asked to create a script that will update records from the old account to the new account (caller, opened_by, assigned_to, etc) for all the different tables in use. I think I have a handle on all that and how to do it.
What I am asking though, is checking the old and new accounts with their email address... If there is more than one account that has the same email address, I do not want the script to proceed. SetLimit(1) would be if I just wanted ot grab the first account found and go, but I actually want it to STOP if more than one account is found. How do I achieve that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 01:23 PM
If it's a one time script you want to run, you can use the GlideRecord getRowCount() method, to evaluate the number of records after you do .query(). docs
Remove your set limit, and validate with getRowCount(), then only execute if the result = 1
If it would be something you need to use often, change it to a GlideAggregate : docs
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 01:23 PM
If it's a one time script you want to run, you can use the GlideRecord getRowCount() method, to evaluate the number of records after you do .query(). docs
Remove your set limit, and validate with getRowCount(), then only execute if the result = 1
If it would be something you need to use often, change it to a GlideAggregate : docs
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 05:29 AM
This is exactly what I needed, thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2024 01:47 PM - edited 10-14-2024 01:51 PM
Hi @jlaps ,
You can try the below code & modify accordingly and it should address your requirement,
If this address your question, please mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das