Hide sales from users who are no stakeholder

Last update:
Created :
Written by Support InfoBridge

Overview

How to hide sales from users who are no stakeholder

How to

This is possible with special criteria. The trick is that you have to choose the Rule Criteria Target: Sale Entire record.
As Operator use Is the current user not a stakeholder of the sale.

Note: This is only available from version 4.14. If you have an older version please read below how to achieve the same result using a C sharp expression.

In version before 4.14 there is no special criteria you can use. The way to hide the sales in those versions can be achieved by using a C sharp expression like this example below

using InfoBridge.DataDirector.Core;
using InfoBridge.DataDirector.Core.SO;
using SuperOffice.CRM.Cache;
using SuperOffice.CRM.Data;
using SuperOffice.Data;
using SuperOffice.Data.SQL;

public class DefaultExpression : IExpressionCriteria
{
    public bool EvaluateExpression(int AssociateId, int GroupId, int RecordId, object Value)
    {
        int PersonId = AssociateCache.GetCurrent().GetAssociatePersonId(AssociateId);
        var Q = S.NewSelect();
        var T = TablesInfo.GetSaleStakeholderTableInfo();
        Q.ReturnFields.Add(S.FieldExpression.Count(T.SaleStakeholderId));
        Q.Restriction = T.PersonId.Equal(S.Parameter(PersonId));
        Q.RestrictionAnd(T.SaleId.Equal(S.Parameter(RecordId)));
        Q.AddIgnoreAutoSentryTableInfo(T);
        return EqualsHelper.GetCountAsBoolean(ref Q);
    }
}

This checks if the current associate is a stakeholder of the sale (RecordId), to reverse it (NOT a stakeholder), put a ! right before EqualsHelper.GetCountAsBoolean(ref Q);

 

Here is an example of how these special operators work for project:
https://kb.infobridge.com/hc/en-us/articles/360009068054

Here is an example of how these special operators work for contact:
https://kb.infobridge.com/hc/en-us/articles/115001926785