Jump to content

Script problem: Remove container file from a record. Trying to transition to JSON to pass multiple parameters.


Recommended Posts

Posted

Hi all,

I have spent all day stuck on this script. I am trying to "retrofit" this script by using JSON to pass multiple parameters into the script. I have attached two screenshots.

SCREENSHOT NAME: script_with_variable_not_working.png

This screenshot shows all script steps, PLUS, I commented in the beginning of the script the JSON I am using as Optional Script Parameters. This screenshot also shows an overlay of the dataviewer showing the incorrect results of the variable "$_container_field_name".

SCREENSHOT NAME: script_set_field_by_name_not_working.png

This screenshot shows line 16 throws the error message in red at the bottom: [102] Field is missing

I strongly suspect the problem lies is me trying to pass the field name of a CONTAINER type field using JSON. As a test, I tried switching to a TEXT type field and I was able to pass that as a variable.

GOAL:

  1. To remove a PICTURE or FILE from a container field, without deleting the record.
  2. To "parameterize" and use "variables" in this script so I can consolidate my scripts ( I need to stop making basically the same script over and over.)

APPROACH:

I wanted to pass two parameters using JSON so I can use:

  • one parameter for the FILENAME in the Custom Dialog presented to User when deleting the container data;
  • the second parameter to use as the field in which to use the Set Field script step to clear the content of the container.

Any help is appreciated, thanks.

 

script_with_variable_not_working.png

script_set_field_by_name_not_working.png

Posted (edited)
12 hours ago, dmontano said:

I strongly suspect the problem lies is me trying to pass the field name of a CONTAINER type field using JSON.

From what I can see the problem is that you are passing the container field's value instead of its name.

Try defining the script parameter along the lines of =

JSONSetElement ( "" ;
[ "container_field_name" ; GetFieldName ( document::document_file ) ; JSONString ] ;
[ "container_file_name" ; document::document_filename ; JSONString ]
)


You could also get by with:

JSONSetElement ( "" ;
[ "container_field_name" ; "document::document_file" ; JSONString ] ;
[ "container_file_name" ; document::document_filename ; JSONString ]
)

but this would break if you renamed the container field.

 

 

Edited by comment
Posted
On 6/25/2025 at 12:38 AM, comment said:

Try defining the script parameter along the lines of =

JSONSetElement ( "" ;
[ "container_field_name" ; GetFieldName ( document::document_file ) ; JSONString ] ;
[ "container_file_name" ; document::document_filename ; JSONString ]
)

Hi Comment - this was exactly the solution.

I appreciate your time and effort - thank you.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.