You are viewing limited content. For full access, please sign in.

Question

Question

Workflow Update Data

asked on July 23, 2015

I want to update each corresponding column in SQL if the retrieved field values are not null. Is there a way using Update Query to only update the field if not null. I am hoping I do not have to do a conditional sequence for 'not null' on every retrieved value before the Update Query? Thanks in advance.

1 0

Replies

replied on July 30, 2015 Show version history

 Hi Bonnie,

Which database are you updating? Altering Repository databases through workflow is generally not supported because it can cause irreparable damage if done incorrectly.

If you are updating External Tables (it sounds like you are), I would recommend using a Custom Query. I have written an example query and I will walk you through it.

You retrieve field values and some of them are blank (Column2 and Column4):

(Figure 1)

You now want Workflow to update a SQL table, called "Table_Name", with the above field values. You only want the field values that are NOT blank to update SQL.

In your Workflow, you retrieve the field values, and then create a Custom Query:

(Figure 2)

The SQL code can be seen more clearly here:

UPDATE 
        Table_Name
SET
	Column1 = ISNULL(NULLIF(?, ''), Column1),
	Column2 = ISNULL(NULLIF(?, ''), Column2),
	Column3 = ISNULL(NULLIF(?, ''), Column3),
	Column4 = ISNULL(NULLIF(?, ''), Column4)
WHERE
	Criteria_Column1 = ?
        AND 
        Criteria_Column2 = ?;

Going through the code:

Table_Name is the table you're updating. Below SET, Column1 through Column4 are the names of the columns you want to update. Criteria_Column1 and Criteria_Column2 are the names of the columns that match your criteria (First Name and Last Name, for example).

The question marks are place holders for your field values, and are read top-down. This means the first question mark in the code is matched up with first question mark in your Parameter Names (Figure 2). These parameters names have Parameter Values (Figure 2) that are set with tokens made by the Retrieve Field Values tool.

Here is a test to show how this Custom Query acts on a table:

            

The Custom Query updated the table with only field values that were NOT empty (Figure 1), and left the other columns alone.

Please let me know if you need help configuring this to your system.

2 0
replied on July 23, 2015

I believe there is not a way but I'd love this to be a feature request!!! (Maybe a checkbox next to each field that says "ignore if data is null?")

I'm always running into this situation with dates in particular. 

Plus it would be faster if there was no need to use multiple, separate update queries for the same entry. 

1 0
replied on November 13, 2019 Show version history

I find it a bit frustrating that you have to write a custom query with update/insert logic just to update field data that has changed - seems like functionality that should be built-in. 

It's bad enough I'm creating an external table just to be able to integrate Forms and the repository; now I have to write custom CRUD scripts too... 

replied on November 13, 2019

Can you tell us more about what you're trying to accomplish? (maybe in a separate thread so we this one doesn't go off track)

You can check whether a (field) value is empty using a Conditional Sequence and put the update/insert activity inside so it only runs when the conditions are satisfied.

You are not allowed to follow up in this post.

Sign in to reply to this post.