Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7163 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I'm having variable results with the attached script. In my database each job may have a load of tasks per employee. When the employee has completed each task they can press a button, run a script and the task is deleted from the list of tasks. They access this button from the 'Job Book' Table which shows the tasks as related records in a portal.

Most of the time, it works beautifully, BUT every now and again it deletes the Main (PARENT) record rather than the Related (CHILD). This causes absolute chaos. Each time it has done it, I have tried to get it to do it again, but it doesn't and our employees always shut it down in a panic and can't remember what they've done.

Is there something I can add to or adjust the script so it doesn't do this ever?

TaskCompleted.pdf

Posted

The script is interesting, you have a halt prior to the delete record, really nothing should happen.

Without the halt step, the script will switch to the layout, delete whatever record that layout last had, then return to another layout. I would suggest adding a find to look for the record(s) that need to be deleted. If the task to be deleted is in a portal, have the script more like this:

GoToLayout (tasklayout)

set error capture ( on ) -- so users don't get an error if nothing is found

EnterFindMode, no pause

SetField(ID,get ( scriptparameter ) ) where ID is some bit of data that uniquely identifies this record.

Perform find

If ( get ( foundcount ) > 0 ) -- only delete if record found

delete record

end if

goto previous layout

Now create a button in the portal listing the tasks, I usually make a small trash can. Click on that button, Format->Button... and select the above made script, passing parameter using the relationship for that portal choosing the unique ID.

This method will make sure the selected task will be deleted. Another tip, instead of deleting the record, you could change something in the task to indicate that it has been completed so it will not show up on the portal, but there in case you need to document that it was completed and by whom.

Posted

Thanks - there shouldn't be a halt - that was where I was testing it!

Actually, originally I didn't want the tasks deleted but every week we run a report that shows everything by Job No (Parent) and include the tasks (CHild) However, if I try to omit the child record because the task box is checked as being completed, it omits the Parent record as well and more confusion reigns. Ideally, I would have liked to keep a record of the tasks but it isn't the end of the world if I don't.

Posted

Instead of omitting, create a new field in Tasks called Status, autoenter, "Active". Any new task will automatically have Active in this field. In the Parent, create a calculation field, cActive, "Active", make sure it is a text field. Now in your relationships include these fields and you will only show active tasks in the portal. Add this to your finds in Tasks and you will only find active tasks. Whenever you tire of seeing a task record, set field to something other than Active and it will "disappear".

If your parent goes away whenever you omit a task, it sounds like you are viewing the task via a portal and as omit only omits the record you are on, which is the parent in this situation, you will make the parent disappear, or delete if user hits delete record.

If you are trying to print the tasks for a parent, create a layout based upon task, one task per record. Then create a script to find all tasks for that parent, and print. It is much easier than trying to print a layout based upon parent with tasks shown through a portal.

Posted

Many thanks - although I resolved deleting the records in a slightly different way, I used your script as a starting point. I decided that it would be too much of a brain drain to undertake your second answer (I have to present this on Monday and it is quite a slow process for me) but I will certainly look at this later.

Once again, thankyou

This topic is 7163 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.