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
AFAIK there is no supported way of doing this. I tried it without success recently.
Thank you for quick response Stefan.
Out of curiosity, what is your use case?
System should store the current state (sorting / filtering preferences) in DB at user level. so whenever user returns to the home, can retain the state as it was.
OK. I just tried my last trick using externalize(). Does not work :-(
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!
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?
Ahh yes I see your problem - the problem is actually saving the field result out of the sort info. I agree that I don't see a great result beyond using the UUID of the field as the key in the mapping rule.
Even though there is no solution found for aforementioned Problem with casting.
I found the solution for the use case though. Instead of storing the record field, I stored sorting info directly using externalize function in database. used internalize function to convert it back.
This way it is retaining the Fields and its type as it is.
This work for my use case. But Solution for record field casting from text type is still not found.
/*While storing it into database*/ externalize(a!pagingInfo( 1, 50, a!sortInfo(recordType!Request.fields.id, false)) /*we can use internalize function back to convert back to original format*/
Thank you and Peter Lewis for spending time on this.