How do I make a field in the employee profile editable? On employee center.

Dario Idrovo1
Tera Contributor

Hello, I need to make two fields editable in the employee profile page of the employee center portal (see attachment) I figured a write ACL with a role of hrsp employee would allow for this to be editable, but this did not work. 

 

I need to make location and channel preference editable, same way pronouns and bio are editable (see pencil next to it)

 

DarioIdrovo1_0-1694534335735.png

 

#employeeprofile #employeecenter #portal 

 

2 REPLIES 2

Carl-Johan
Tera Expert

Maybe you found the solution already, but maybe it will help others at least 🙂

You have to add the fields to the script include called ep_portalUtil in order to make a field editable - like this exsample:

var ep_portalUtil = Class.create();
ep_portalUtil.prototype = Object.extendsObject(ep_portalUtilSNC, {
    initialize: function() {
        ep_portalUtilSNC.prototype.initialize.apply(this, arguments);

        this.editableFields = {
            'short_bio': {
                maxlength: 255,
                fieldType: 'textarea'
            },
            'nickname': {
                maxlength: 40,
                fieldType: 'string'
            },
            'preferred_pronoun': {
                fieldType: 'choice',
                options: this.getChoiceFieldOptions('preferred_pronoun')
            },
            'u_auto_approve_limit': {
                fieldType: 'string'
            }
        };
    },
   

    type: 'ep_portalUtil'
});

 

 

This will work so long as the field you're adding resides on the employee profile [sn_employee_profile] record itself. It won't work if you're dot-walking to, say the user record.

This is because the 'updateEditableFields' function only runs a .update() against the employee profile record: it can't handle dot walked fields being updated.

Also, I suggest adding to the existing 'editableFields' object as opposed to replacing the entire object to ensure future app updates will still be able to be used!

 

To fix this, you can edit the 'updateEditableFields' function in the 'ep_portalUtil' Script Include, e.g.:

var ep_portalUtil = Class.create();
ep_portalUtil.prototype = Object.extendsObject(ep_portalUtilSNC, {
    initialize: function(userId) {
        ep_portalUtilSNC.prototype.initialize.apply(this, arguments);
		//add to the editableFields object instead of replacing it to ensure future app updates are inherited
		this.editableFields['user.mobile_phone'] = { 
			maxlength: 12,
			fieldType: 'string'
		}
    },
	
	updateEditableFields: function(field, value) {
		if (field.substring(0,5) == 'user.'){ //if we're dot walking to the sys_user table
			var dwField = field.substring(5,field.length);
			this.sysUserGR.setValue(dwField, value);
			this.sysUserGR.update();
		}
		else ep_portalUtilSNC.prototype.updateEditableFields.apply(this, arguments); //fallback on OOB
    },

    type: 'ep_portalUtil'
});

 

Till ServiceNow fix this, you'll need a workaround such as the above, which will handle fields dot-walked to the sys_user table.

 

Please mark this as helpful if this has helped you.

Happy coding!