Tuesday 1 June 2021

How to check if a customer contains a specific Location Role and find the Logistics Location Id for that specific location role

 Below method will check if a customer contains a specific Location Role or not and find the Logistics Location Id for that specific location role:


This is where you can check the location role for a customer:






public LogisticsLocationId getLogisticsLocationId(CustAccount _custAccount)

{

        DirPartyAddressLocationRoleNames    locationRoleNames;

        DirPartyPostalAddressView                   addressView;

        LogisticsLocation                                   logisticsLocation;

        CustTable                                               custTable = CustTable::find(_custAccount);


        select firstonly PartyLocation from addressView

            where addressView.Party == custTable.Party;


        locationRoleNames = addressView.locationRoles();


        str billTo = 'Bill to'; // Here you should write the name of your location role which needs to be find out.

        if (strScan(locationRoleNames, billTo, 1, strLen(locationRoleNames)))

        {

            DirPartyLocation dirPartyLocation;

            select firstonly LocationId from logisticsLocation

                join Location from dirPartyLocation

                    where logisticsLocation.RecId ==  dirPartyLocation.Location

                        && dirPartyLocation.Party == custTable.Party;

        }


        return logisticsLocation.LocationId;

    }


No comments:

Post a Comment

Insert/Update or remove the default dimension value in D365 FSCM via x++

Use below method to insert/update the dimension values, just pass the parameter values to the method and it will return the updated value: p...