Expand my Community achievements bar.

Latest Community Ideas Review is Out: Discover What’s New and What to Expect!

API - posting null values

Avatar

Level 10
It seems the WF API won’t let you push ‘blank’ values once you have already saved a value. We created a custom form on the project where the user can select values (being pulled in via the API from another system) and save them to the Project Custom Form (eg., 'Campaign Details'). They also need to be able to wipe out those values, if necessary. So say user goes in and assigns project 123 to campaign details 'abc'. Then a few days later, they realize this project shouldn't be associated to any campaign, so they try to 'erase' the abc campaign value from the custom form. We get an error when we try to go wipe out a value in this field, after its been initially saved. Any ideas?
11 Replies

Avatar

Level 10
Hi Katherine, I hadn't yet tried to do this via the API, but after having a try and reading the documentation, I don't see a way to do this with Workfront's API. From consulting Dr. Google, other APIs often allow you to do a PUT with the word null as the field contents, as opposed to normal field contents being in "double quotation marks". Perhaps Doug Den Hoed might know how to do this. Otherwise, please log a ticket with Support and then let us know the answer here! Thanks

Avatar

Community Advisor
Thanks David. From memory, I think Null (capitalized) might do the trick. Regards, Doug

Avatar

Level 10
Thanks Doug - will give that a try!

Avatar

Community Advisor
Sorry, Katherine: I'd remembered incorrectly. From my notes, it appears that null (all lower case, as David first suggested) is the appropriate syntax to try (vs Null). Regards, Doug

Avatar

Level 10
Per my developer, we've tried both NULL and null - and neither work.

Avatar

Level 2
Hi Katherine, You initially wrote that the user can select values on the custom form. Which type of form are you using? Is this a value on that form you want to remove (see: value in an input), or do you want to remove the option from the form completely? Some custom form fields are a little more "sticky" than normal base API fields. Even within custom forms sending a 'null' will work sometimes, but not always. It's mainly only used for simple fields on an object, or top-level collections. As Custom Forms are represented by different nested internal objects, and those objects may represent different data types, we sometimes have to change what is required. In some cases, we actually just accept no-data (empty string) to clear out the field. If the field is required, we completely block null / no-data from being saved and you must include one of the required options. Let me know the type of form/forms, and I can respond to the specific use case. If you can also include the error you are seeing, that will also help. Thanks!

Avatar

Level 10
Hi Haven, I have been testing with a text custom field (just a regular text box). I can set it with any text I like - no problems. However, if I try to PUT a blank value I get the following error: " class ": " com.attask.common.ValueRequiredException " " message ": " A value is required for Customer Name. It cannot be an empty value. " If I try to pass the word "Null" or "null" or "NULL", it just stores that in the text box. Interestingly, if I instead try to update a Drop-Down Custom Field, I can send a blank value and it removes whatever was previously selected. This is what I want to do with the regular text field (and probably what Katherine is trying to do). Regards, David

Avatar

Level 2

In Reply to David Cornwell:

<blockquote>

Hi Haven,

I have been testing with a text custom field (just a regular text box). I can set it with any text I like - no problems.

However, if I try to PUT a blank value I get the following error:

" class ": " com.attask.common.ValueRequiredException " " message ": " A value is required for Customer Name. It cannot be an empty value. "

If I try to pass the word "Null" or "null" or "NULL", it just stores that in the text box.

Interestingly, if I instead try to update a Drop-Down Custom Field, I can send a blank value and it removes whatever was previously selected. This is what I want to do with the regular text field (and probably what Katherine is trying to do).

Regards, David

</blockquote>

Hi David, The error here states that a value is required for your field "Customer Name." It is correct that the API is blocking you from saving any empty value. If you were to look at that field via the UI, you would see the "Make a required Field" as checked (screenshot attached). For the Drop-Down field, check to see if it is required or not. If it is not required, I would expect an empty string to work here. A 'null' would not work here, as it would instead look for an option by the name of "null."0690z000007ZkFxAAK.png

Avatar

Level 10
Ah, you're right, Haven! Something as simple as that option being set on the custom field. :) So, I'm now a believer and see no reason why we can't clear a custom field via the API. Katherine...perhaps check the same thing...is it set as a Required field? Regards, David

Avatar

Level 10
THanks all! Its a project custom form. Some of the fields were required, so I've undone that piece and can wipe out the values directly via the project details>custom form. We are displaying an external page (populated with values from another system) in an iframe (and then via the API, pushing their selections back to the custom form) - and that's where I wanted the user to be able to wipe out the values - but I think we will just need to direct them to the custom form itself if they need to remove values completely.

Avatar

Level 10
Hi Katherine, I may not understand fully what you want, but assuming you want users of this external page to be able to trigger the clearing of custom fields via the API, you should be able to do that via the API based on what I tested today. You shouldn't have to direct users to clear the fields directly on the custom form. Regards, David.