Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Create a record on custom table

vahini
Giga Guru

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. 

 

 

2 REPLIES 2

Eshwar Reddy
Kilo Sage

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

AakashG1357
Giga Contributor

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.

AakashG1357_0-1727325190255.png

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.

AakashG1357_1-1727325206803.png

Step3 - Add "Else" condition from Flow Logic which will automatically run if Request Type is Remove User.

AakashG1357_2-1727325216429.png

Step4 -  Add "Look Up Record" Action by selecting a Custom Table followed by query that you want to make to find the record.

AakashG1357_4-1727325252556.png

Step5 - Add "Delete Record" Action to delete a record resulted from above action.

AakashG1357_3-1727325227781.png

 

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: -

AakashG1357_5-1727325329907.png

 

Regards

Aakash Garg