Reply PhotoChange functionality of Contact on Employee

Hi everyone!

How are you?

I hope you can help me!

I need that in EmployeePage the Photo are not ReadOnly and it has funcionallity as in Contact. I saw that in attributes Section of EmployeePage(Base), there a attribute called ContactPhoto that refers to Contact.Photo and in the Init Method, this attribute is assigned to "primaryImageColumnName".I don't understand why "primaryImageColumnName" not is a attribute of Employee. What is its source?

To replicate this functionally, I did the following on EmployeePage (Custom):

  • I changed the attribute "ReadOnly" to False in array values of photoProperty in Diff section
  • I add "OnPhotoChange" attribute in array values of photoProperty in Diff section
  • I add OnPhotoChange and onPhotoUploaded to methods section 
//diff
{
	"operation": "merge",
	"parentName": "PhotoContainer",
	"propertyName": "items",
	"name": "Photo",
	"values": {
		"getSrcMethod": "getSchemaImageUrl",
		"readonly": false,
		"onPhotoChange": "onPhotoChange",
		"defaultImage": Terrasoft.ImageUrlBuilder.getUrl(resources.localizableImages.DefaultPhoto),
		"generator": "ImageCustomGeneratorV2.generateCustomImageControl"
	}
},
 
...
//methods
onPhotoChange: function(photo) {
				if (!photo) {
 
					this.set(this.primaryImageColumnName, null);
					return;
				}
				this.Terrasoft.ImageApi.upload({
					file: photo,
					onComplete: this.onPhotoUploaded,
					onError: this.Terrasoft.emptyFn,
					scope: this
				});
			},
 
onPhotoUploaded: function(imageId) {
				debugger;
				var imageData = {
					value: imageId,
					displayValue: "Photo"
				};
				this.set(this.primaryImageColumnName, imageData);
			}

 

With this configuration, I can change the photo, but when I refresh or exit and return to the Page,the photo is reset with default image, I think it is not being recorded correctly in the contact photo column. What am I doing wrong? What is missing?

Thanks in advance.

King Regards,

 

Ezequiel

Like 0

Like

1 comments
Show all comments