Adding Attachments to a Custom Object

  • 1
  • Question
  • Updated 4 years ago
New to Skuid. We have a custom object Service_Type__c that has attachments. We created a Skuid page for the Service_Type object, preview no problem. Add a Model called Attachments and select the Attachment object. Add a condition, Attachment records where ParentId is the Id paramter in the page's url, condition always on. We preview and get the following: Id FROM Attachment WHERE (ParentId = '2619551') LIMIT 21 Error:invalid ID field: 2619551. Clearly we have an issue with param. Thanks.
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
It does look like your parameter is causing a problem.  My guess is that you are passing Service_Type__c record name value in the parameter instead of the record ID.  A good clue is that your error message has a 7 digit number rather than an ID (which is usually 15 or 18 digits). 

If you don't want to fix the parameter, you can change the Attachment condition so that it does not source the parameter,  but rather retrieves attachments whose ParentId are in a field from another model.  That would be the Service_Type_c model  - and its Id field.

Hopefully that will get you going.  Let us know if you have other questions.  Thanks for being new to Skuid!  
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb
Well, when we look at the attachment. It is Related to 2619551, the Service_Type__c Name. Our condition for the Service Model is Service_Type__c records where Name is the Id parameter in the page's url. If I remove the Attachment Model, preview, use 2619551, my record displays with no issue. If I add the model for the Attachment, and the condition above, we get the error. If I take the SF ID of the Service_Type__C record and paste it in place of 2619551 after rendering the preview, we get a JSON string exceeds heap size limit message. skuid__ui?page=Service2015&id=a0qF0000008zL4x, instead of skuid__ui?page=Service2015&id=2619551. This document has 5 attachments and we do not have the Body field in the Skuid layout.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Hmm.  This is interesting. 

The Apex heap size is probably caused because the condition on your Attachments model is getting ignored and you are trying to retrieve all the attachments in your database. 

A few more things to try. 

1. Make sure the condition on your attachments is set to "Abort the Model's condition" if there are no rows in the source model.  (See the picture below. 



2. Make sure the models are in the right order.  The Service Model needs to be quieried berfore the Attachments model.  So Service needs to be ABOVE attachments in your list. 
Photo of Ben

Ben

  • 780 Points 500 badge 2x thumb
Changed the setting, it was set to ignore. Ran it, everything is the sale. This custom object is an Auto-Number field, but not sure that should matter and everything is in the right order. We only added a couple fields, a couple tabs and then tried to add a related list. Very basic.
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
I'm a little confused. 

If this is not working, would you mind giving us login rights to your org so we can take a look at what is going on?   Here is how: 1. Use this tutorial to give us login rights: http://help.skuidify.com/m/getting-started/l/182412-getting-help-how-to-grant-skuid-login-rights-to-...

2. Then send an email to support@skuidify.com  with your org Id, the name of the page, and a viable record that will show the problem happening. 

We'll see what's going on...