How to cast record field in the format of text (#"urn:appian:record-field:...../.....) to record field?

Certified Lead Developer

Hi ,

when I sort on a record backed read only grid , sort field that is stored is in the format #"urn:appian:record-field:v1:ff132d24-cf88-4234-88ae-9fe224dd3dfd/b05761f7-3e63-4e76-bb2b-10c4886815d8.

I need to store this sorting preference for each user level. This is not being stored in record field type. its type is string. Even if i want to cast it to record field I am getting error that cast invalid.

Only way i could find to covert this into a record field is by using eval() function. But eval() function is a hidden one. Can some one give me an idea on how to handle this?

Thank you

  Discussion posts and replies are publicly visible

Parents
  • The only way I can think of doing this is to have some kind of mapping rule. In that rule you could have a list of key value pairs that have a field name and the field reference, and then just store the field name in the database. Then, use your mapping rule to return the corresponding field as needed. Here's the mapping from text to record field (you likely also need one the other direction to determine what to save in the database):

    It would certainly depend on how dynamic your interface is - like if this could be across dozens of record types the maintenance would be difficult keeping up with all of these fields - but if it's only a single record type this might work!

  • 0
    Certified Lead Developer
    in reply to Peter Lewis

    Hi Peter,

    I did already use a rule to map the field alias and record fields as you have shown. 

    It has two functionalities. if i pass text key , it will return corresponding record field. and if i pass record field it will return the text key. It is working fine.

    But the problem here is the how to pass the record field value from parent rule to this rule.

    i have to pass like below.

    /*Here if i am expecting key as output
      so I am passing recordfield and returnKey attributes*/
    
    rule!APP_fetchRecordAttributeByValue(
        key_txt:null,
        value_recordField: ri!paginginfo.sort.field,
        returnKey_bool:true
        )

    in the above code segment, value_recordField parameter, is not evaluating it to a record field ,but to a text field. so it is not returning key i am expecting.

    But below code segment works, with eval function.

    rule!APP_fetchRecordAttributeByValue(
        key_txt:null,
        value_recordField: eval(ri!paginginfo.sort.field),
        returnKey_bool:true
        )

    I know i should not use hidden function , but is there any other way around for this?

Reply
  • 0
    Certified Lead Developer
    in reply to Peter Lewis

    Hi Peter,

    I did already use a rule to map the field alias and record fields as you have shown. 

    It has two functionalities. if i pass text key , it will return corresponding record field. and if i pass record field it will return the text key. It is working fine.

    But the problem here is the how to pass the record field value from parent rule to this rule.

    i have to pass like below.

    /*Here if i am expecting key as output
      so I am passing recordfield and returnKey attributes*/
    
    rule!APP_fetchRecordAttributeByValue(
        key_txt:null,
        value_recordField: ri!paginginfo.sort.field,
        returnKey_bool:true
        )

    in the above code segment, value_recordField parameter, is not evaluating it to a record field ,but to a text field. so it is not returning key i am expecting.

    But below code segment works, with eval function.

    rule!APP_fetchRecordAttributeByValue(
        key_txt:null,
        value_recordField: eval(ri!paginginfo.sort.field),
        returnKey_bool:true
        )

    I know i should not use hidden function , but is there any other way around for this?

Children