How to add attachments to a business object

In this example, we will look at:

  • Adding file attacments to previously created edit form

1. Adding file attacments to previously created edit form

1.1 Open Form section. Click on “Invoice_Edit” form in the Forms grid. 1.2 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “AttachmentsRow”, Order field with 30, choose “Form. ROW BEGIN”as Template. Click Save and Exit button. 1.3 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “AttachmentsCol”, Order field with 31, choose “Form. COL BEGIN”as Template.

Click on Load params button near Template params label. You will see:

@Title=
@HSize=6
@DivId=

in Template params field. Fill this field as:

@Title=Attachments
@HSize=12

Click on the Save and Exit button.

1.4 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “AttachmentsMain”, Order field with 32, choose “Dependent files”as Template.

Click on Load params button near Template params label. You will see:

@Prefix=form
@ViewName=
@Width=
@Height=
@BaseEntityIdName=
@BaseEntityIdValue=@id
@CustomSave=true
@TableName=

in Template params field. Fill this field as:

@Prefix=form
@ViewName=UploadedFiles
@Height=250px
@BaseEntityIdName=ObjectId
@BaseEntityIdValue=@id
@CustomSave=true
@TableName=Invoice

Click on the Save and Exit button.

1.5 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “AttachmetsColEnd”, Order field with 33, choose “Form. COL END”as Template. Click Save and Exit button. 1.6 To add new Block in this Form click on Create link button above of the Blocks grid. Fill Name field with “AttachmentsRowEnd”, Order field with 34, choose “Form. ROW END”as Template. Click Save and Exit button. 1.7 Now to attachments was saved with the main record we need to change FormCustomSave function in Source field.

Change (line 5)

var stores = [
    optimajet.container.form_InvoiceDetail_store,
];

to

var stores = [
    optimajet.container.form_InvoiceDetail_store,
    optimajet.container.form_UploadedFiles_store,
];

Click on the Save button.

Screenshots:

Screenshot 1

Now you can attach files to your invoices.