IC SunsetThe developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this forum will no longer be available. More details available on our FAQ.
Topic
  • 12 replies
  • Latest Post - ‏2019-08-16T08:16:15Z by QuikJean
RockstarKimL
RockstarKimL
5 Posts

Pinned topic Delete table row

‏2018-02-13T17:56:17Z | 8.6

I'm a relatively new BPM developer and I'm stumped on something basic deleting a row in a table. We are using version 8.6 with built in Spark controls. I have a table bound to a list of objects. I need to call a ServiceFlow whenever we delete a row from the table. I clicked the checkbox to show a delete button and it DOES remove it from the table, but does not fire a boundary event, so I don't see a way to call a service flow to remove the item from the database. So instead, I added a column with a button. From the diagram view, I was able to select the button as the boundary event to the service flow. However, I can't figure out how to get the ID of the selected item. The service flow expects one ID variable. I tried tw.local.MYOBJECT.listSelected.itemID, but got an error.

 
 
  • QuikJean
    QuikJean
    133 Posts
    ACCEPTED ANSWER

    Re: Delete table row

    ‏2018-02-15T13:42:51Z  

    I understand the last half and that is a BIG help! The only part I didn't follow is this:

    - Create your Service Call object

    Are you talking about an object on the diagram tab of the Client Side Human Service? Or do you mean to create a coach view? It sounds like you mean to create an object on the diagram but I don't see anything about auto run and when I try to call the object from the event, I get an error "View 'SC_Delete' from view /TEST_Template1/TEST_Template1 is not found"

    I am talking in the Coach itself, same place you created your table.

    Above or below your table, you drag and drop a new control "Service Call"

     

    In this new object properties, give it a right control Id

     

    In the configuration tab, create a new service flow (so you get the right input / output variables format)

    leave input value and autorun as default

  • QuikJean
    QuikJean
    133 Posts

    Re: Delete table row

    ‏2018-02-14T07:01:48Z  

    I think there is an easier way using the provided table.

    In the events of the Table object there is a "on deleting row" event.

    this event provides you with an "item" object where you can list its properties doing "item.myProperty"

    so in this event you can code a call to Service Call object that does the DB delete based on the item properties like ID or key

    Updated on 2018-02-14T10:32:23Z at 2018-02-14T10:32:23Z by QuikJean
  • RockstarKimL
    RockstarKimL
    5 Posts

    Re: Delete table row

    ‏2018-02-14T19:35:41Z  

    That's true, I can access the item ID of the row being deleted. However, I can't figure out how to call a service flow from there.

  • QuikJean
    QuikJean
    133 Posts

    Re: Delete table row

    ‏2018-02-15T07:34:00Z  

    That's true, I can access the item ID of the row being deleted. However, I can't figure out how to call a service flow from there.

    - Create your Service Call object

    - In the configuration tab map the right Service Flow (make sure to respect the input/output variables format - best way to do that is to click New from there), do not assign any input value and uncheck "autorun"

    - In the general tab give it a right "Control_ID" like 'SC_DeleteRow'

    - In the 'On Deleting Row' event of the table, just add this line

    ${SC_DeleteRow}.execute(item.id);

    Updated on 2018-02-15T07:39:34Z at 2018-02-15T07:39:34Z by QuikJean
  • RockstarKimL
    RockstarKimL
    5 Posts

    Re: Delete table row

    ‏2018-02-15T13:26:04Z  
    • QuikJean
    • ‏2018-02-15T07:34:00Z

    - Create your Service Call object

    - In the configuration tab map the right Service Flow (make sure to respect the input/output variables format - best way to do that is to click New from there), do not assign any input value and uncheck "autorun"

    - In the general tab give it a right "Control_ID" like 'SC_DeleteRow'

    - In the 'On Deleting Row' event of the table, just add this line

    ${SC_DeleteRow}.execute(item.id);

    I understand the last half and that is a BIG help! The only part I didn't follow is this:

    - Create your Service Call object

    Are you talking about an object on the diagram tab of the Client Side Human Service? Or do you mean to create a coach view? It sounds like you mean to create an object on the diagram but I don't see anything about auto run and when I try to call the object from the event, I get an error "View 'SC_Delete' from view /TEST_Template1/TEST_Template1 is not found"

  • QuikJean
    QuikJean
    133 Posts

    Re: Delete table row

    ‏2018-02-15T13:42:51Z  

    I understand the last half and that is a BIG help! The only part I didn't follow is this:

    - Create your Service Call object

    Are you talking about an object on the diagram tab of the Client Side Human Service? Or do you mean to create a coach view? It sounds like you mean to create an object on the diagram but I don't see anything about auto run and when I try to call the object from the event, I get an error "View 'SC_Delete' from view /TEST_Template1/TEST_Template1 is not found"

    I am talking in the Coach itself, same place you created your table.

    Above or below your table, you drag and drop a new control "Service Call"

     

    In this new object properties, give it a right control Id

     

    In the configuration tab, create a new service flow (so you get the right input / output variables format)

    leave input value and autorun as default

  • RockstarKimL
    RockstarKimL
    5 Posts

    Re: Delete table row

    ‏2018-02-15T14:06:32Z  

    I understand the last half and that is a BIG help! The only part I didn't follow is this:

    - Create your Service Call object

    Are you talking about an object on the diagram tab of the Client Side Human Service? Or do you mean to create a coach view? It sounds like you mean to create an object on the diagram but I don't see anything about auto run and when I try to call the object from the event, I get an error "View 'SC_Delete' from view /TEST_Template1/TEST_Template1 is not found"

    I just found the Service Call object that you're talking about! I'm on a roll now...

  • RockstarKimL
    RockstarKimL
    5 Posts

    Re: Delete table row

    ‏2018-02-20T13:49:42Z  

    I got the delete button to call the service and update the database. Now we want to update records. We want the rows to be read-only and when the user clicks an Edit button, the fields will become editable and there will be a save button and a cancel button. Any tips on how to achieve this?

  • QuikJean
    QuikJean
    133 Posts

    Re: Delete table row

    ‏2018-02-21T09:22:30Z  

    I got the delete button to call the service and update the database. Now we want to update records. We want the rows to be read-only and when the user clicks an Edit button, the fields will become editable and there will be a save button and a cancel button. Any tips on how to achieve this?

    Well unless there is a hidden function the doc says that you cannot change the rendering of a column after the table has been displayed... so I assume neither the cell rendering

    so my suggestion would be that when the end user clicks on the edit button it enables a "Modal Section" in which you have controls (Text controls, Integer controls, etc) with a copy of the selected row values.

    once the user clicks ok, you copy the new values back to the table and save them to the DB.

  • Deb2013
    Deb2013
    54 Posts

    Re: Delete table row

    ‏2019-08-05T00:22:03Z  
    • QuikJean
    • ‏2018-02-14T07:01:48Z

    I think there is an easier way using the provided table.

    In the events of the Table object there is a "on deleting row" event.

    this event provides you with an "item" object where you can list its properties doing "item.myProperty"

    so in this event you can code a call to Service Call object that does the DB delete based on the item properties like ID or key

    Hi QuickJean,

    I dont see the "on deleting row" event in Service Data Table events. Any idea. Please refer to the screen shot.

     

    Thanks in advance.

    Attachments

  • QuikJean
    QuikJean
    133 Posts

    Re: Delete table row

    ‏2019-08-05T09:03:51Z  
    • Deb2013
    • ‏2019-08-05T00:22:03Z

    Hi QuickJean,

    I dont see the "on deleting row" event in Service Data Table events. Any idea. Please refer to the screen shot.

     

    Thanks in advance.

    With a Service Data Table there is no "on deleting row" but only with Table.

    What are you trying to achieve ?

  • Deb2013
    Deb2013
    54 Posts

    Re: Delete table row

    ‏2019-08-05T13:31:06Z  
    • QuikJean
    • ‏2019-08-05T09:03:51Z

    With a Service Data Table there is no "on deleting row" but only with Table.

    What are you trying to achieve ?

    Thanks QuickJean for your response.

     Requirement is to delete record from the table (one by one or multiple at a time) and upon deletion service will be called to get data deleted from DB as well.

     

    Regards,

    Deb 

  • QuikJean
    QuikJean
    133 Posts

    Re: Delete table row

    ‏2019-08-16T08:16:15Z  
    • Deb2013
    • ‏2019-08-05T13:31:06Z

    Thanks QuickJean for your response.

     Requirement is to delete record from the table (one by one or multiple at a time) and upon deletion service will be called to get data deleted from DB as well.

     

    Regards,

    Deb 

    Sorry I have been off for a while. In case you are still looking for a solution, you need 3 controls :

    - your Service Data Table

    - a Button named Delete or whatever

    - a Service Call control

    Configure your Service Data Table as normal with Selection enabled and that's it.

     

    Configure your Button with a piece of code in the onClick event like this - this extracts the data that is selected and turns it into a json string that is sent as input to the Service Call

    ${Service_Call1}.execute(JSON.stringify(${Service_Data_Table1}.getSelectedRecords(true)));
    

     

    Within the Service Flow that is behind the Service Call, you can do something like :

    var tmp = JSON.parse(tw.local.data);
    for(var i = 0 ; i < tmp.length ; i++)
    {
        // extract IDs or whatever
    }
    

    to be able to read the data again and do the delete in the DB. tmp is an javascript array (not a BPM list) that you can loop to call the DB delete.

     

    Finally in the onResult event of the Service Call, you just need to call a refresh of the Service Data Table

    ${Service_Data_Table1}.refresh();
    

     

     

    I thought there was a way to delete the lines after the call without a refresh but Service Data Table does not allow removing lines with removeRecord method... even though it's in the documentation

     

     

    Updated on 2019-08-16T08:18:51Z at 2019-08-16T08:18:51Z by QuikJean