Jump to content
  • 0

Simple trigger solution needed


Colnocode

Question

I have many projects and each project has many tasks. Each time we start a new project staff spend hours loading in all the tasks.

In very many cases we already have a project where the tasks are very similar. If the staff could copy/duplicate the tasks from the similar project and just replace the project_id with the project_id of the new project, then the team could save hours by just adjusting the tasks that were different.

I have a Table TBL_Project_Tasks and it holds the tasks for all projects. Each record holds Task_id; Project_id; Task Description; Task_sequence; Task comment and some other fields that are not important.

I have a simple Datasheet that I created and it writes to a new second Table TBL_New_Projects. It has User-id and time_stamp (for records only); Copy_from_Project_id; Copy_to_Project_id.

I wanted to create a trigger in TBL_New_Projects so that when a new record was inserted into TBL_New_Projects, all the records in TBL_Project_Tasks where the Project_id = Copy_from_Project_id were duplicated but with the Project-id replaced by Copy_to_Project_id.

The team can just use our regular ‘Edit_Task’ datapage to adjust any tasks they need

I have spent hours with the Triggered action and it seems I just do not have the knowledge to make this work ( I am a beginner after all).

 

Can you help??

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Looking at the trigger, it seems that there will be two actions upon Insert.

You mentioned that the "Copy_from_Project_id were duplicated but with the Project-id replaced by Copy_to_Project_id."

Meaning to say, you would duplicate the record, but the original record would be replaced by Copy_to_Project_id.  Tell me if I understand this correctly, I would be glad to help you out with this one. :)

Looking forward to your response! 

Link to comment
Share on other sites

  • 0

Hi Glitch,

Almost correct :). I need for the new (inserted copy) TASK records to have the Copy_to_Project_id.   (I.E I do not wish to change the original  TASK records , because they  should be considered  as if they were a template ). 

I am excited to see how to solve this, it looked so simple and will save so much time almost  immediately !!

Link to comment
Share on other sites

  • 0

One question though, I'm currently looking into this trigger and it's quite tricky.

Upon Insert on TBL_New_Projects, ALL the records from TBL_Project_Tasks where the Project_id = Copy_from_Project_id will be copied to WHICH table?

It's harder than I thought :D

Link to comment
Share on other sites

  • 0

Hey @Colnocode,

I think I got it to work, however I used three tables instead, where the copy of all records who meets the Where Clause will be placed. 

The trigger goes like this: 

Screenshot_1.thumb.png.262acd49d10ae34210d22d5f3399eea0.png

Currently the Task Table would contain values so that we can compare the #Inserted Project ID to the Copy_To..

Screenshot_2.png.9e74442c6e413b4f3106d6389c20594e.png

So for example, I inserted a record inside New Project who's Copy_To_Project_ID is equals 1, the third table will copy Task1, 2 and 3. 

Here's the output:

1.) http://prntscr.com/n3ru1n

2.) http://prntscr.com/n3ruol

 

I have also attached the app I created, ifever you're interested in testing it.

 

TRIGGER_SAMPLE.zip

 

I hope this helps!

 

Link to comment
Share on other sites

  • 0

Hi  Glitch,

Two Messages - First one first

"Upon Insert on TBL_New_Projects, ALL the records from TBL_Project_Tasks where the Project_id = Copy_from_Project_id will be copied to WHICH table" 

Answer :- to The original table I.E TBL_Project_Tasks

Second message .

I am not really sure what the third table is used for ?  I am going to give it a try and see what happens it looks promising to me . It looks like you got a whole lot further with this than I could , Thanks. Give me a  day or two to try it out 

Cheers

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...