Skip to main content
August 14, 2021
Question

image error using query record

  • August 14, 2021
  • 10 replies
  • 0 views

Hi 

I am using query record to fetch data from the database.Whenever i am using  query record to fetch image , its giving this error.

I am using this code to get the image displayed on the interface:

a!imageField(
images: a!documentImage(
document: todocument(index(ri!employee,'recordType!{89956f33-9ae6-45d8-9fb3-c45b6cc5877c} Request.fields.{87357f56-96ee-41b0-a7db-1972b5ab8161}imageid',null),)

),

),

Its giving me this error:

Could not display interface. Please check definition and inputs.
Interface Def inition: Expression evaluation error at function a!imageField [line 4]: The image at index 1 in an image gallery component [label=""] has an invalid value for "document". "document" must not be null.

    10 replies

    stefanhelzle0001
    Brainy
    August 14, 2021

    Did you check the actual values in database? If that field is not required, you might want to add a null-check to the field.

    Add a showWhen to hide the field if there is no image

    showWhen: not(isnull(index(ri!employee,'recordType!{89956f33-9ae6-45d8-9fb3-c45b6cc5877c} Request.fields.{87357f56-96ee-41b0-a7db-1972b5ab8161}imageid',null)))

    August 14, 2021

    Yes , I did check the database and there are no null values for image.

    stefanhelzle0001
    Brainy
    August 14, 2021

    Then your indexing is wrong as it returns null. You use the request record type to index into a rule input named employee. Did you check that?

    aparajitas0001
    August 16, 2021

    Looks like the document value in DB is null. Even if now, always add null check for values that allows null values. I think the indexing is wrong as well. The recordType is added to 2nd parameter even though first parameter is a rule input. This looks wrong. Is the rule input of the cdt type which has image id? is the data passed in that rule input? If not then just give record type by itself.