How to check if a customer record has a particular employee as its sales team member using SuiteQL

In SuiteQL, directly verifying whether a specific employee belongs to the sales team associated with a customer record can be challenging, as the sales team members are stored as a sublist. We can utilize the table “CustomerSalesTeam” to achieve the desired functionality. The table defines the relationship between customers and their respective sales team members. This table effectively consolidates the sales team sublist into a structured format.

Code:

let suiteql = `select c.id, c.entityid, c.companyname from customer c join CustomerSalesTeam cst on c.id=cst.customer where cst.employee=${employeeId}`;

        let queryResult = query.runSuiteQL({ query: suiteql }).asMappedResults();

        for (let i = 0; i < queryResult.length; i++) {

          let internalid = queryResult[i].id;

          let name = queryResult[i].companyname;

          log.error(“Internal id: “+internalid ,”Name: “+name);

        }

Leave a comment

Your email address will not be published. Required fields are marked *