Skip to main content
chrisg0006
February 7, 2024
Question

Casting from Record Type Field to a Folder

  • February 7, 2024
  • 12 replies
  • 0 views

I want to keep documents from each speaker in a separate folder.  I create the folder in a separate process and store the name of the folder in a field the Record Type of Speaker.  Now when I want to upload documents, I need to set the Folder parameter in the a!fileUploadField().  When I set the target to the field, i get an error that Appian cannot cast the value of Record Field into a type of folder.  I guess that I have to use the Cast() function to do that. However, I can not figure out how to format the Cast function to do that.  I read the documentation for Cast() and TypeOf(), but I am still lost.

target: cast( typeof("folder"),'recordType!PMSO Speaker.fields.folder'),

Could someone please let me know how to proceed?

12 replies

stefanhelzle0001
February 7, 2024

Folder are identified by a numeric integer value, so tointeger will do it. You can also use tofolder().

harshitb6843
February 7, 2024

Groups, Documents, and Folders on Appian have unique integer IDs for themselves. So wrapping any of these types in tointeger() will give you their ID. 

abhayd3663
February 7, 2024

Instead of folder name, you should store the unique folder id. During file upload you won't be require to cast, you may use the record field directly.

target: fv!row['recordType!PMSO Speaker.fields.folder'],

chrisg0006
February 12, 2024

Thank you to everyone that responded.  This is how i was able to fix my issue.

1. I changed the format of the folder field in the database from Text to Integer.

2. In the process model in the Create Folder smart service where I create the folder for the speaker, I created a custom output. tointeger(ac!NewFolder) and saved that to the folder id field in the speaker record.

3. In the Interface is set the target to: target: tofolder(ri!speakerRecord['recordType!PMSO Speaker.fields.speakerFolderId']),

Works like a champ!!!  Thanks again!

stefanhelzle0001
February 12, 2024

Great to hear that.

In step 2, you can just assign the new created folder to that field. Appian will do the typing automatically. That makes the custom output unnecessary.

Appian is very good in getting the type correctly casted when assigning values. Not so much when comparing.

chrisg0006
February 12, 2024

I tried that and still got an error.  It seems that neither the text (cast from text to folder) or the integer field alone (cast integer to folder) did the trick.  The to folder() function did it.