Question

Disable contact's link in section list page

Hi all,

We have a custom section, which contains a contact field (label = Member): http://prntscr.com/luc7de

In the list view, this contact is clickable (clicking the contact name will redirect user to the contact page itself)

Now we want to make this field not clickable for specific user role. They are allowed to see the contact name, but thay are not allowed to click to the contact page where all info can be seen.

I tried this in the 'UsrReservations1Section'-page behind the 'onEntityInitialized'-method:

$("a").each(function() {

    var linkId = $(this).attr("id");

    var href = $(this).attr("href");

    var n = href.indexOf("ContactPage");

    if (n > 0) {

        document.getElementById(linkId).style.cursor = "default";

        document.getElementById(linkId).style.pointerEvents = "none";

        document.getElementById(linkId).style.color = "black";

    }

});

But this does not work...

Any ideas or advice would be appreciated!

Kind regards,

Vincent

Like 0

Like

3 comments

Hello Vincent,



Here is an example how to disable "Account" filed on Contact section.



Best regards,

Alex

define("ContactSectionV2", ["GridUtilitiesV2"], function(GridUtilities) {
	return {
		entitySchemaName: "Contact",
		details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
		diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/,
		methods: {
			prepareResponseCollection: function(collection) {
				this.callParent(arguments);
				collection.each(this.removeLink, this);
			},
 
			removeLink: function(item) {
				var AccountId = item.values.Account.value;
				if(AccountId != undefined) { 
					item.customStyle = {"pointerEvents": "none"} 
				}
 
			}
		}
	};
});

 

Hi Alex,

 

Thank you for the feedback.

I slightly modified your code, since it would only be applicable for one specific user:

            prepareResponseCollectionItem: function(collection) {

                this.callParent(arguments);

                var currentUser = Terrasoft.SysValue.CURRENT_USER.value;

                if (currentUser === "ff64c809-3ff0-4d10-b096-a9c351db37cb") {

                    collection.each(this.removeLink, this);

                }

            },

            removeLink: function(item) {

                var MemberId = item.values.UsrMember.value;

                if(MemberId !== undefined) { 

                    item.customStyle = {"pointerEvents": "none"};

                }

            }

But I am getting following error in the console: http://prntscr.com/lvylzy

--> message: TypeError: n.each is not a function

Any idea what went wrong?

 

Kind regards,

Vincent

Vincent Tahon,

Unfortunately, it`s hard to say what exactly goes wrong. You should debug your code via devtools. At first you should check where exception is raising. Then check the value and type of "n" variable.

Basically, It seems that "each" function doesn`t exist in "n" object.



How to debug client code:

https://academy.bpmonline.com/documents/technic-sdk/7-13/client-code-de…

Best regards,

Alex

 

Show all comments