I've used the javascript below to set the value for the property TestProp1 to green ("TestProp1", "green"). Now I want to unset the value. Using the script below, I've tried CEObject.getProperties().putValue("TestProp1", null); but the script errors with (string.null) is ambiguous. What's the correct syntax or method to set a property to null making it as if it was never set?
Script that does not work: importClass(Packages.com.filenet.api.property.Properties); importClass(Packages.com.filenet.api.constants.RefreshMode);
function OnCustomProcess (CEObject) { CEObject.refresh(); CEObject.getProperties().putValue("TestProp1", null); CEObject.save(RefreshMode.REFRESH); }
Answer by Sharlya (448) | Feb 01, 2017 at 10:54 AM
When a property is being added, you can use the method putValue. When an existing value needs to be unset, (nulled out and left empty - as if it was never set) use putObjectValue which will overwrite the current value and set to null:
Script that works: importClass(Packages.com.filenet.api.property.Properties); importClass(Packages.com.filenet.api.constants.RefreshMode);
function OnCustomProcess (CEObject) { CEObject.refresh(); CEObject.getProperties().putObjectValue("TestProp1", null); CEObject.save(RefreshMode.REFRESH); }
How can I stop E_BAD_PARAMETER errors from filling the p8 logs? 1 Answer
Unable to create datasource in ACCE due to lenght error 1 Answer
Save Button in Daeja ViewONE Virtual 2 Answers
P8 CPE 5.2.1 error: FNRCC0110E - ERROR FixedContentProviderCache.getProvider failed to init provider 1 Answer
How to delete all documents from an object store in P8 5.2.1? 1 Answer