Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

EP: Quary Issue (display redundant data)

$
0
0

Below is output for SmmOpportnitylistGrid ( Credit to: gl00mie ) now my only issue is, the Query for Superior it copy to display 5 times. In other hands, salesman data was display fine hope anyone could guide me on the query below:

Aot\Data Sets\smmOpportunityList\Data Sources\smmOpportunityTable\Methods\init

------Init-----

smmOpportunityOwnerId currentOwnerId; // declare variables for further usage
QueryBuildDataSource  qbdsSalesmenList;
Range                 rangeStr;

// get an EmplId for the user who's logged on to EP and check if there's a mapping
currentOwnerId = SysCompanyUserInfo::find(curUserId()).EmplId;
if (!currentOwnerId)
{
    // current EP user doesn't seem to be an employee
    throw error("Can't show you employees' opportunities");
}
// display opportunities owned either by the current logged on EP user
// or by supervised salesmen
qbdsSalesmenList = queryBuildDataSource.addDataSource(tablenum(SM_CRM_Salesman));


// we use an implicit inner join between smmOpportunityTable and SM_CRM_Salesman
// format the query range expression
  rangeStr = strFmt('((%1.%2==%4.%5)&&(%4.%6=="%3")))',
                  queryBuildDataSource.name(),
                  fieldStr(smmOpportunityTable, OwnerId),
                  currentOwnerId,
                  qbdsSalesmenList.name(),
                  fieldStr(CSM_CRM_Salesman, Salesman),
                  fieldStr(CSM_CRM_Salesman, Superior)
                  ); 
queryBuildDataSource.addRange(fieldNum(smmOpportunityTable, OwnerId)).value(rangeStr);

---------------------Reference-------------------

smmOpportunityOwnerId currentOwnerId;
smmOpportunityTable   smmOpportunityTable;
SM_CRM_Salesman       salesmanHierarchyList;
;
currentOwnerId = SysCompanyUserInfo::find(curUserId()).EmplId;
select * from smmOpportunityTable
    join    salesmanHierarchyList
    where   (       smmOpportunityTable.OwnerId    == currentOwnerId
            ||  (   smmOpportunityTable.OwnerId    == salesmanHierarchyList.Salesman
                &&  salesmanHierarchyList.Superior == currentOwnerId
                )
            );

-------------------------------------------------------


Viewing all articles
Browse latest Browse all 72043

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>