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.
Discussion posts and replies are publicly visible
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)))
Yes , I did check the database and there are no null values for image.
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?
Yes I did but couldn’t figure out the error for null values
There is no error. The data type you use as rule input "employee" does not have a field named "imageid".
Question: Is ri!employee of type recordtype!Request?
Yes the rule input has field imageId and it’s a type of record type.
OK. Did you try to not use index() and the square bracket syntax instead? I am asking because if your rule input is of the correct record type, there is no need for index() as that field does always exist.
When do you get the error? In designer?
BTW, todocument() is also not necessary. Appian will happily consume a numeric value.
It’s coming in designer but when I checked site page the image is there.
Then, this is because you did not provide any test data. Click "Test" top right and do that, then your interface will render fine.
I typically try to create my interfaces in a way they do not show errors, even without any data.
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.