Empty Record giving display Errors

Hi All,

I have a page in my site pointing to a record. When I don't specify any default filters, I am able to fetch all the rows from the database table and display in the record. But when I am giving a filter on the user who inserted the record into the table, it is giving me error.

When the query "user_txt" is null, I am getting the error

"The Requested Record Type is Not Available: Cannot apply operator [EQUALS] to field [user_txt] when comparing to value [TypedValue[it=11, v={abanda}]].{APNX-1-4203-015}"

I was not able to find a solution in the forum except removing the UI on a whole with a showonly condition in case of a null set.

Please assist if anyone has worked on a fix on this.

 

Thanks,

Adi

  Discussion posts and replies are publicly visible

Parents Reply
  • Hi bradc,

    Here you go. I should have included these in the original to avoid all the confusion.

    1. This is my default filter. The database has records inserted by users from one of 4 different groups. So the below rule in the filter gets the groupname of the logged in user and gives it as input to the record list and gets the groupname.

     

    2. When the fetched group name has records in the database (count > 0), I am able to successfully display the results.

     

    3. When the group users have not inserted any records into the database, and the record set returns 0 records, I am getting the error.

    And this is the error I want to fix. When the 3rd scenario occurs and the result set returns 0 records, i would like to display an empty page instead of this error.

     

    Hello    I am able to fetch the user group without any issue by passing the loggedInUser() and I have no errors anywhere as long as the resultset has records for that user group. 

    Thanks,!

Children
  • +2
    Certified Lead Developer
    in reply to AdirajuB
    I would suggest modifying your rule to return a single text field. Your filter is using the equals operator but your rule returns a list (Appian type 103) and you get the error shown above.
  • Your rule getUserGroup(loggedInUser()) is returning a List of Text String, which is type 103 as you see in the error. You cannot use the "=" operator for a list of values, which is why you're receiving the error. To fix this, make sure that rule will only ever return a single value and that the response is of the same type as "audience_txt". Also, depending on the format of that rule, it may be returning an empty array ({}) which is being treated like a list of text string even though it looks null.
  • - Josh and Meg have provided the same solution I would suggest as your solution.
  • Thank you Josh. I have put a tostring before the first line of my rule to cast the result as a string whatever the result is. It is working fine now.

    My rule is a composition of if and else condition with multiple if classes. The weird thing (and why I think it was working fine for a particular user group) is, if the first if condition is true, the rule is returning a Text object, if it is false, for any subsequent if condition becoming true, the rule is returning a type 103.

    My rule:

    if(ismemberof(loggedInUser(), "Group 1"),
    tostring(tointeger(groupname("Group 1"))),
    {
    if(ismemberof(loggedInUser(), "Group 2"),
    tostring(tointeger(groupname("Group 2"))),
    {
    if(ismemberof(loggedInUser(), "Group 3"),
    tostring(tointeger(groupname("Group 3"))),
    },
    loggedInUser()
    },loggedInUser()
    )

    If the logged in user is from Group 1, I am getting the correct value as a Text type. But if the user belongs to any other group (2 or 3 or 4 and so on), I am getting a List of Text (type 103). I tried to fix it but couldn't do anything. So I have changed my rule slightly to return string value for whatever the outcome of the if condition is. And it is working fine.

    The rule, I have written from my memory so is absolutely wrong. I just wanted to show the representation of the rule.

    tostring(
    if(ismemberof(loggedInUser(), "Group 1"),
    tostring(tointeger(groupname("Group 1"))),
    {
    if(ismemberof(loggedInUser(), "Group 2"),
    tostring(tointeger(groupname("Group 2"))),
    {
    if(ismemberof(loggedInUser(), "Group 3"),
    tostring(tointeger(groupname("Group 3"))),
    },
    loggedInUser()
    },loggedInUser()
    )
    )

    Thanks,
    Adi
  • 0
    Certified Lead Developer
    in reply to AdirajuB
    Try updating the rule to be

    if(ismemberof(loggedInUser(), "Group 1"),
    tostring(tointeger(groupname("Group 1"))),
    if(ismemberof(loggedInUser(), "Group 2"),
    tostring(tointeger(groupname("Group 2"))),
    if(ismemberof(loggedInUser(), "Group 3"),
    tostring(tointeger(groupname("Group 3"))),
    loggedInUser()
    )
    )
    )