In C4C there is an option to upload Product Image and the Product Image can be made available to Output forms. Image which is available in the Product Master can be used on the quote Output forms. But in one of my client requirement client want to show 2 images on the Output forms i.e Product Image and Line Diagram Image. Since the Product Image is attached to Product Header, but for line diagram image of the product we have uploaded the same in the Attachments tab at Products with the file name same as Product External ID.
Standard Product Image:
Additional Image to be uploaded in attachments tab at Products with the External ID as the name for image
Product Image is stored as Attachment Type as Product Image by default. Also the attachment Type for another image is of type Standard .
In the SDK an additional extension field is created to tore the image data. Since the data from attachment is read in form of Binary Content. But in sdk extension field cannot be created of type binary object. hence a text type extension field was created and the data from the image is fetched in form of binary data and converted to hexadecimal string and is stored in extension variable.
Please find SDK Code below to read attachments and convert it to binary object and then to hexadecimal string
//Product Attachment
//Fetch All the attachments
var prod_att = item.ItemProduct.Material_V1.AttachmentFolder;
//Fetch the External ID of the product
var ext = item.ExternalID;
//Fetch the Product UUID
var prod_uuid = item.ItemProduct.Material_V1.UUID.content;
Apply Loop on all the attachments
foreach(var doc in prod_att.Document){
var type = doc.TypeCode.content;
var name = doc.Name;
if(!ext.IsInitial()){
var indic = doc.Name.Contains(ext);
//Fetch the details of the attachment whose name starts with External ID name and the type of attachment is standard
if(( indic.ToString() == "X") && (type == "10001")) {
var content = doc.FileContent;
//Convert the File content to Binary data
var bin_content = content.BinaryObject.content;
if(!bin_content.IsInitial()){
//Convert the binary content to string since extension field cannot hold on binary content
var base_content = Binary.ToBase64String(bin_content);
//Populate the fetched details into the extension field
item.prod_image = base_content;
}
}
}
}
Now our extension field contains the details of the additional image. Now extend this extension fields to forms by right clicking on Extension Business object and choosing the option Enhance Forms.
Now through easy form editor make both the fields available in Output forms
Here in below diagram it shows the standard Product Image
In the below diagram it shows the extension field ProductImage
In the adobe forms it is declared as image field. Also initially it is bound to Text field with field format Rich Text below:
In the below image it shows the binding to custom extension field
Final field where image is shown is of Image type
On executing the output forms we can see both the images: