​​​How to update and delete items from another list?

Last Update: June 22, 2018

In this scenario, we will describe how to update and delete items from a list named "States" from within "Countries" list. Here are the steps on how to do that:

  1. Open the form in design mode.
  2. Press on Auto Populate icon in the View Group in the Form Ribbon.
  3. Add a Repeater control to the form design workspace.
  4. Add 2 labels, 3 textboxes and 2 buttons controls inside the repeater as appear in the following screenshot:
    How to update and delete items from another list1.jpg
  5. Select an empty space in the form design workspace to add a new Form Rule.
  6. In the Rules pane, click on the Add icon to add a new rule, the Rule Manager dialog will open.
    How to auto-shifting Panel control in a form2.jpg
  7. Add a new rule as follows:
    A. Update the Rule Name as desired.
    B. Change the Rule Type to Action.
    C. Keep the Event Type onLoad.
    D. In the Action section, type the following script:
        populateRepeaterFromList(Repeater1, '/', 'State', "<Query><Where><Eq><FieldRef Name='CountryCode'/>
       <Value Type='Text'>" + getValue(txtCountryCode) +"</Value></Eq></Where></Query>",
       ['ID', 'CountryCode', 'StateCode', 'StateName'], ['txtStateID', 'txtCountryCode', 'txtStateCode', 'txtStateName']);
    E. Click on the Save button to save the rule.
    Note: You can use Assistance Panel to help you adding functions and related parameters, form variables and form controls to Conditions and/or Actions sections.
  8. Select the btnDeleteState button control.
  9. In the Rules pane, click on the Add icon to add a new rule, the Rule Manager dialog will open.
    How to auto-shifting Panel control in a form2.jpg
  10. Add a new rule as follows:
    A. Update the Rule Name if desired.
    B. Change the Rule Type to Action.
    C. Change the Event Type to onClick.
    D. In the Condition section, type the following:
        getValue(txtStateID) != ''
    E. In the Action section, type the following script:
        var status = deleteListItems('/', 'State',
        "<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Text'>" + getValue(txtStateID) +"</Value></Eq></Where></Query>"  )
        if (status == true){
      alert('The item has been deleted successfully')
       }
    F. Click on the Save button to save the rule.
  11. Select the btnUpdateState button control.
  12. In the Rules pane, click on the Add icon to add a new rule, the Rule Manager dialog will open.
    How to auto-shifting Panel control in a form2.jpg
  13. 13. Add a new rule as follows:
    A. Update the Rule Name if desired.
    B. Change the Rule Type to Action.
    C. Change the Event Type to onClick.
    D. In the Condition section, type the following:
    getValue(txtStateID) != ''
    E. In the Action section, type the following script:
        var status = updateListItems('/', 'State',
      "<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Text'>" + getValue(txtStateID) +"</Value></Eq></Where> </Query>",​['StateCode', 'StateName', 'CountryCode'], [getValue(txtStateCode), getValue(txtStateName), getValue(txtCountCode)])
        if (status == true){
        alert('The item has been updated successfully')
        }
    F. Click on the Save button to save the rule.
  14. Publish the form by clicking on the Publish button in the Publishing Group in the Form Ribbon.
  15. Test the form by clicking on an existing item in the list.

Related Resources:
These resources may not reflect the same exact case steps.
https://www.youtube.com/embed/8ckDRORV3gQ