Dynamically assign parent model to file upload component

  • 1
  • Question
  • Updated 1 year ago
  • Answered
Is there a way I can dynamically assign a model to a file upload component?

I am trying to create a generic page to display attachments, which will also allow users to upload new attachments and use this page as a page include across a variety of object record detail pages.

Zach helped me here https://community.skuid.com/skuid/topics/get-sobject-name-from-salesforce-id with building a map of salesforce key prefixes and the corresponding object names dynamically. I am making use of this map to check against the id of the salesforce record, determining the sObject and am able to build the object model on the fly using javascript. Now, I have a file upload component on my page, to which I want to assign this newly created model.

Is there anyway I can do this? Is there any documentation on this?
Photo of Ashwat

Ashwat

  • 768 Points 500 badge 2x thumb

Posted 1 year ago

  • 1
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Yes. It sounds like you're talking about the parent model chosen on the File Upload.

The documentation can be found here:
https://docs.skuid.com/latest/en/skuid/components/file-upload/index.html#file-upload
Photo of Ashwat

Ashwat

  • 768 Points 500 badge 2x thumb
***UPDATE***

So this is what I did. I created a generic model (called it GenericModel) on the account object (because the file upload component needs a parent model assigned to it).

And then on page load, I have a snippet that changes the 'objectName' property to the object of the salesforce record that was passed and also set a condition on the model to the id of the salesforce record that was passed to the page include. 

And that did the job!

I know I am getting the result that I want but would this be the right approach or is there a better way to achieve this?
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Thank you for posting your solution!