Need a recipe for fileupload. Store uploaded file in documents folder and the document Id to be stored in DB table.

 Need a recipe for fileupload. Store uploaded file in documents folder and the document Id to be stored in DB table. To facilitate an API GET type, to retrieve uploaded document with document Id.

Please an example recipe. I have tried using fileUpload component and used a!writetoDataStoreEntity() as follows and it is throwing an error stating the valueToStore cannot be null, when trying to upload a file.

Error for the below code is:

Could not display interface. Please check definition and inputs.

Interface Definition: Expression evaluation error: An error occurred while executing a smart service: An error occurred while trying to convert the given data to the type of the specified entity “Technologies” [id=db1da466-b3a3-4e93-bd4a-81566d516b20@4053, type=Technologies (id=2670)] (data store: Radar_DataStore). Value that could not be converted: ActivityClassParameter[name=DynamicInputs,it=3,v=[Document:4089]] Details: Could not cast from Text to Technologies. Details: CastInvalid (APNX-1-4400-000) This error will not be displayed to the user viewing this form. Click here to dismiss the error message and see the resulting interface.

 

Need to store only Document Id on DB not the image itself. Image should be stored in folder configured on the fileUpload component.

 

=load(
a!gridLayout(
label: "",
instructions: "This is a grid layout",
headerCells: {
a!gridLayoutHeaderCell(label: "Image")
},
rows: {
a!gridRowLayout(
contents: {
a!fileUploadField(
helptooltip: "Upload Technology image Files",
target: cons!ImagesFolder_Constant,
value: ri!Image.Image,
/*error("Unable to Store Uploaded Image")*/
saveInto: a!save(ri!Image.Image, save!value)
)
}
)
}
)
)

  Discussion posts and replies are publicly visible

Parents
  • Tried some changes with below code:
    a!formLayout(
    label: "Form",
    contents: {
    a!textField(
    label:"Technology Name",
    value: ri!Technologies.Name,
    saveInto: a!save(ri!Technologies.Name, save!value)
    ),
    a!integerField(
    label: "Opportunity Rating",
    value: ri!Technologies.OpportunityRating,
    saveInto: a!save(ri!Technologies.OpportunityRating, save!value)
    ),
    a!integerField(
    label: "Risk Rating",
    value: ri!Technologies.RiskRating,
    saveInto: a!save(ri!Technologies.RiskRating, save!value)
    ),
    a!textField(
    label: "Years To Impact",
    value: ri!Technologies.YearsToImpact,
    saveInto: a!save(ri!Technologies.YearsToImpact, save!value)
    ),
    a!textField(
    label: "Impact",
    value: ri!Technologies.Impact,
    saveInto: a!save(ri!Technologies.Impact, save!value)
    ),
    a!fileUploadField(
    label: "Images",
    value: ri!Technologies.Images,
    saveInto: a!save(ri!Technologies.Images, save!value)
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidgetSubmit(
    label: "Submit",
    saveInto: a!writeToDataStoreEntity(cons!DataStore_Technologies_Constants,
    ri!Technologies,
    "Success",
    ""),
    submit: true,
    style: "PRIMARY"
    )
    }
    )
    )

    This up clicking submit button is not doing anything and not showing any error. Document not uploaded and content not saved to DB. Anything wrong with the code please?

    Noticed that [Document: 1234] is the format of document info being passed into an array of text column in DB. But, for an Array of Text we need something to be in the format { "1234" } with just document number in strong form, how to achieve this? what is best possible way of storing multiple document numbers as an array in a column for each record?

  • 0
    A Score Level 2
    in reply to anushas0002
    Hi Anushas,
    What is the data type of the ri!Technologies.Images? you can type cast the value into toInteger and then store it to ri!Technologies.Images
  • It is integer array. It is saving now as expected. Thank You
Reply Children
No Data