User input task

Hello,

In the "user input task" there is an option "Allow users to save a draft of in-progress tasks".

I'd like to know if there was a way to launch the save draft by the system, I mean if we can do the save without an user's action (click on the button or do the "ctrl+s" shortcut).

We need to be able to have kind of "auto save" of the current form.

Do you think that is possible ?

Thank you

  Discussion posts and replies are publicly visible

Parents
  • Also agree there is nothing natively OOTB that will allow auto-saving of forms.  However, as the a!writeToDataStoreEntity() function could be called from any field's saveInto parameter, if this were my requirement I would create a rule that takes the CDT input and writes to the DB using this function, as the others have suggested - plugged into each field's saveInto.  Along these lines, if nothing has changed on the form, what is the use case requiring auto-saving of unchanged data?

    Purely food for thought, we can call fn!executeStoredProcedure() within a refreshVariable.  Note this function is not designed to call procedures which alter and data within the DB - however it does allow this in some situations.  I cannot speak to if this will change in the future.  However, I have 2 cases in production where data is inserted or updated using this, such as a proxy function which runs on task assignment and updates a logging table if a proxy assignment is made, and a round robin task assignment procedure that maintains the task assignment history and pulls the next assignee.

    In the example below, we are not writing to the DB, but a procedure is called which adds 10 to the local!input value and returns the output.  This procedure is fired on each local!input field change, OR after each 30 seconds (based on local!save being refreshed), without any changes to the field saveInto's.  With some modifications it may be possible to load data into the DB with this method.

    Some other use cases that may benefit from fn!executeStoredProcedure() within a local variable load could be for logging any interface views, etc.

    =a!localVariables(
      local!input: 10,
      local!save: a!refreshVariable(
        value: now(),
        refreshInterval: 0.5
      ),
      local!output: a!refreshVariable(
        value: fn!executestoredprocedure(
          dataSourceName: "java:comp/env/jdbc/sql_lookup",
          proceedureName: "usp_testAdd10",
          inputs: {
            {name: "NUM", value: local!input}
          }
        ),
        refreshOnVarChange: local!save
      ),
      {
        a!textField(
          label: "Input",
          labelPosition: "ADJACENT",
          value: local!input,
          saveInto:  local!input,
        ),
        a!textField(
          label: "Output",
          labelPosition: "ADJACENT",
          value: local!output.parameters.RESULT,
          readOnly: true
        ),
        a!textField(
          label: "Last Save",
          labelPosition: "ADJACENT",
          value: local!save,
          readOnly: true
        )
      }
    )

    Procedure:

    SET ANSI_NULLS ON
    GO
    
    SET QUOTED_IDENTIFIER ON
    GO
    
    
    CREATE PROCEDURE [dbo].[usp_testAdd10] 
    	@NUM varchar(15),
    	@RESULT varchar(16) OUTPUT
    AS
    BEGIN
    	SET @RESULT = cast((cast(@NUM as int) + 10) as varchar(16))
    
    	RETURN
    END
    
    
    GO

Reply
  • Also agree there is nothing natively OOTB that will allow auto-saving of forms.  However, as the a!writeToDataStoreEntity() function could be called from any field's saveInto parameter, if this were my requirement I would create a rule that takes the CDT input and writes to the DB using this function, as the others have suggested - plugged into each field's saveInto.  Along these lines, if nothing has changed on the form, what is the use case requiring auto-saving of unchanged data?

    Purely food for thought, we can call fn!executeStoredProcedure() within a refreshVariable.  Note this function is not designed to call procedures which alter and data within the DB - however it does allow this in some situations.  I cannot speak to if this will change in the future.  However, I have 2 cases in production where data is inserted or updated using this, such as a proxy function which runs on task assignment and updates a logging table if a proxy assignment is made, and a round robin task assignment procedure that maintains the task assignment history and pulls the next assignee.

    In the example below, we are not writing to the DB, but a procedure is called which adds 10 to the local!input value and returns the output.  This procedure is fired on each local!input field change, OR after each 30 seconds (based on local!save being refreshed), without any changes to the field saveInto's.  With some modifications it may be possible to load data into the DB with this method.

    Some other use cases that may benefit from fn!executeStoredProcedure() within a local variable load could be for logging any interface views, etc.

    =a!localVariables(
      local!input: 10,
      local!save: a!refreshVariable(
        value: now(),
        refreshInterval: 0.5
      ),
      local!output: a!refreshVariable(
        value: fn!executestoredprocedure(
          dataSourceName: "java:comp/env/jdbc/sql_lookup",
          proceedureName: "usp_testAdd10",
          inputs: {
            {name: "NUM", value: local!input}
          }
        ),
        refreshOnVarChange: local!save
      ),
      {
        a!textField(
          label: "Input",
          labelPosition: "ADJACENT",
          value: local!input,
          saveInto:  local!input,
        ),
        a!textField(
          label: "Output",
          labelPosition: "ADJACENT",
          value: local!output.parameters.RESULT,
          readOnly: true
        ),
        a!textField(
          label: "Last Save",
          labelPosition: "ADJACENT",
          value: local!save,
          readOnly: true
        )
      }
    )

    Procedure:

    SET ANSI_NULLS ON
    GO
    
    SET QUOTED_IDENTIFIER ON
    GO
    
    
    CREATE PROCEDURE [dbo].[usp_testAdd10] 
    	@NUM varchar(15),
    	@RESULT varchar(16) OUTPUT
    AS
    BEGIN
    	SET @RESULT = cast((cast(@NUM as int) + 10) as varchar(16))
    
    	RETURN
    END
    
    
    GO

Children