Question

Visibility for portal users

Hi Team

I tried using the below code to check for the current user contact type. This code works as expected for normal users, but when the same code is used in the portal page it is not working.

Below the code:

 

        attributes: {

            "NameAttribute": {

    // Data type.

    "dataValueType": this.Terrasoft.DataValueType.BOOLEAN,

    // Column type.

    "type": this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,

    // Default value.

    "value": "false"

  }

        },

   checkContactType: function() {

                        var currentUser = Terrasoft.SysValue.CURRENT_USER.value;

                        var type;

                //    alert(currentUser);

                    var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {

                        rootSchemaName: "SysAdminUnit"

                            });

                            esq.addColumn("Contact.Type.Name", "TypeName");

                    esq.filters.add("IdFilter", esq.createColumnFilterWithParameter(

                            Terrasoft.ComparisonType.EQUAL, "Id", currentUser));

                        esq.getEntity(currentUser, function(result) {

                    if (result.success) {

                    type = (result.entity.get("TypeName"));

                    if(type !== "Vendor") {

                this.set("NameAttribute", true);

                    //alert(type);

                    }

                    }

                            }, this);

                            var c= this.get("NameAttribute");

                            if(c === true) {

                            return true;

                            }

                },

                   {

                "operation": "insert",

                "name": "UsrEducationListDetailc586f46f",

                "values": {

                    "itemType": 2,

                    "markerValue": "added-detail",

                    "visible": {"bindTo": "checkContactType"}

                },

                "parentName": "Tab38360566TabLabel",

                "propertyName": "items",

                "index": 1

            },

Hoping for a positive reply.

Regards

manikanta K 

Like 0

Like

1 comments

The EntitySchemaQuery doesn't return data due to the luck of access rights to the table "SysAdminUnit" for portal users. However there is a solution. Please follow the instruction below:

1. Create a view which contains all needed data from the table "SysAdminUnit". For example:

CREATE VIEW UsrVwUserInfo

AS

SELECT   

    s.Id,

    s.CreatedOn,

    s.CreatedById,

    s.ModifiedOn,

    s.ModifiedById,

    s.ProcessListeners,

    s.ContactId as UsrContactId,

    c.TypeId as UsrTypeId

FROM

    SysAdminUnit AS s

    INNER JOIN Contact AS c

    ON s.ContactId = c.Id

2. Create an object based on the database view. The article by the link below describes how to do it. Pay attention that the object should be inherited from the Base object, the checkbox "Represent Structure of Database View" must be checked and column names must be the same as in the database view except lookup fields.

UsrContactId in the view - UsrContanct lookup in the object.

https://academy.bpmonline.com/documents/technic-sdk/7-13/localizing-views

3. Set access rights to the newly created object for portal users.

 4. Add the created object to the lookup "List of objects available for portal users". Unfortunately, you can't do that by your own. Please contact your account manager to do it. 

5. Change the EntitySchemaQuery according to the new object.

After that everything will work fine.

   

Show all comments