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

At the moment there is no special criteria you can use like there are for Projects and Contacts

The way to hide the sales 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