Create a record on custom table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 02:09 PM
Hi All,
Can someone help me with script for below requirement.
I got a requirement where a catalog request is submitted, on this catalog item there is a field named
Request type = Add or Remove user.
'Requested for' field ( referenced to user table )
There is a custom table called : u_m365_recovery_tenant_add_or_remove
Two tasks in the flow ( task 1 and task2 )
If request type = Add then after closure of 2nd task a record needs to be inserted on this custom table which has 5 columns ( all these columns are present on user record also )
we have to fetch user in Requested for field and find those 5 fields values and then insert a record on this custom table and populate 5 columns ( Employee number, First name, Last name, Email, Business phone ) with data fetched from user table.
If Request type = Remove then fetch the user in requested for field and then query custom table with Employee number and delete that record from that table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 08:20 PM - edited 09-25-2024 09:59 PM
Hi @vahini
### Steps After Closure of 2 Tasks in Flow
1. **Use Look Up Record Action**: Retrieve the user from the `Requested for` field.
2. **Use If Condition**: Check the value of the "Request type".
- **If the value is "Add"**:
3. **Use Create Record Action**: Create a record in the custom table and populate it with values from the user retrieved in step 1.
- **If the value is "Remove user"**:
4. **Use Delete Record Action**: Delete the corresponding record from the custom table.
If you need any assistance reach out to my mail-> rithickeswar123@gmail.com
Please mark this response as Correct and Helpful if it helps you can mark more that one reply as accepted solution
Thanks
Eshwar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2024 09:44 PM
Hi @vahini,
Hope you are doing well.
Solution Proposed
There can be 2 Solutions/Approaches to this Problem Statement/Task/Activity: -
1. Write a Business Rule for adding and removing the record in/from Custom Table.
2. Add Actions in Flow Designer after closing of 2nd Task.
Approach 1 - Using Business Rule
Step1 - Create a BR on SC Task Table as After-Update by adding a condition when Catalog Task 2 State is Closed Complete.
Step2 - Write a Script to add/remove record in/from Custom Table.
=> Let me know if you need a script, I'll try my best to provide it for the same asap.
Approach 2 - Add Actions in Flow Designer
Step1 - Add "If" condition from Flow Logic just after the second Catalog Task and check if Request Type is Add User.
Step2 - Add "Create or Update Record" Action to add a record in Custom Table by matching the fields available in Custom table with the fields available in User Table.
Step3 - Add "Else" condition from Flow Logic which will automatically run if Request Type is Remove User.
Step4 - Add "Look Up Record" Action by selecting a Custom Table followed by query that you want to make to find the record.
Step5 - Add "Delete Record" Action to delete a record resulted from above action.
As a solution, I personally tried to implement the whole task/activity on my Personal Developer Instance and followed Approach 2, which is quite faster and easy to implement in comparison to Approach 1 and it seems to be work fine for me.
Hope this solution work for you as well.
Attaching a snapshot of complete Flow Designer for the reference: -
Regards
Aakash Garg