I want to have a window pop up after a task is saved

I want the user to save a task and ifs its a certain task type (a custom field) then I need a popup window with the ID of the task on it like

https://www.whatever.com?id=TASK_ID

This window has info for the user to fill out on another system so I cant automate it.

I have found many places I can put this window.open() but no where that has access to the newly created task's ID.

I wanted to add it to the saveAndClose()  but it still doesn't have access to the task id.

Parents Reply Children
  • I think my example works because of two things:

    1. the custom code is inside the callback function so the initiateSave is completed before the callback executes and the id exists.

    2. the bind controls the scope of "this", so that "this" is indeed the same "this" that was just saved, including the id.

  • Sorry to be late to this party but I thought I'd put in my $0.02 (or £0.02 for the UK pop Slight smile ).

    I think  has put you on the right track with looking at a callback function but I also think there may be a better way to accomplish what you are trying.

    If you look at the code for the _saveModel() function in: ./clients/base/views/record/record.js you will find there is an optional callback function that can be called. Crucially for you, this only gets called a) if it exists and b) after the Save has completed successfully - so if there are any errors it doesn't get called.

    To use this, I believe you just need to declare a function in your own custom js code with the name used of: saveCallback(). Note this takes a parameter (true) in the core call so you need to add that in, I think this possibly indicates the success or failure but you might want to grep for other functions to see if they are used elsewhere (I'm afraid I haven't had time to do that yet!). If you declare this function inside your own custom/modules/Tasks/clients/base/views/record/record.js (or potentially in ./custom/modules/Tasks/clients/base/views/create/create.js if you only want it on a Create action specifically) then you can ensure it runs only when Tasks are saved. Also it means you are not overriding any core functions and therefore is more upgrade safe.

    As this will be inside the scope of the Task object and called after the successful Save event I believe the "this" will contain all the saved fields including the id you are after and the field you want to test against for the pop up.

    Unfortunately I have not had time to test this either but hopefully you might find your solution within this area.

    An alternative approach I have just thought of would be to look for the code that actions the "Success" alert popup you get when creating a new record as this is effectively the action you want to replicate. If you see where and how that is done you may be able to override it with your own pop up (this may or may not already use the above callback function somewhere!!).

    Thanks,

    JH.