How to update a lookup column from a K2 Smartform to be empty
kbt139784
PRODUCTObjective
Within Sharepoint you can change the value of a lookup column on a list to be an empty or blank value. You can do this by selecting the (None) option from the Sharepoint form and submitting the form. With K2 Smartforms supplying a blank value will not update the lookup column within Sharepoint to be an empty value. The value for that lookup column will still remain at its previously set value. We need to be able to have an option for users to update the SharePoint lookup column value to be blank while using K2 SmartForms.Before You Begin
Ensure that you have generated K2 SmartForms for a SharePoint list, or have created views/forms that are being used as the default new, edit, and display forms for the Sharepoint list that has our lookup column. Also take note of an alternative workaround that would instead involve giving the lookup column another value of "None" for the user to select. Refer to the below How-To steps for both design paths.How-to Steps
There are two design paths that could be implemented here in order to get the desired behavior. Design #1 is the least invasive.
Design #1: Create a value for our lookup column in the parent list/library that is "None." With this being a selection for the lookup we can have the users select "None" to simulate adding a blank entry to the lookup column. This will require that all users are aware and filter on None when searching for specific data in that list/library instead of a blank value.
Design #2: Create conditional firing of rules that will fire based on whether or not the Smartforms control tied to the lookup column has a value. See below steps for more context:
1. Edit the rule for when the form is submitted and then run the Update List/Library Item Method
2. Insert the condition "a control on a View does not contain a value." Choose the view that holds the lookup column and then the specific dropdown list control tied to the lookup column.
3. Add the execute a view method Action underneath the condition for the control not containing a value. Select the same view as previously used, then select the Update method.
4. Configure the Update method's input mappings. For the input properties on the update method, supply the lookup column with a value of 0. The act of supplying a nonexistent ID for the lookup will cause the update to make the column blank. Save this rule. Ensure all other relevant properties also get populated in the input parameters.
5. Ensure we have configured a condition for when the update method is run and the control does contain a value. By default this should be created if you generated forms.
6. Additionally, if you have multiple lookups you will need to account for those having a value or not with their own condition/update method. Now when the user leaves the dropdown control blank, the condition will fire the update related to changing the lookup to be empty.
Example of Rules: