Showing posts with label lookup. Show all posts
Showing posts with label lookup. Show all posts

Thursday, September 18, 2025

change lookup for documenttype in file upload from leave request

 Scenario:- Today in this blog we see how to alter lookup of document type based on document type in leave request form as shown in image below


 >>To get lookup of all document types write this logic

[ExtensionOf(classstr(DocuUpload))]
internal final class docucoc_Extension
{
    public DocuManagementOptions parmDocuMgmtOptions(DocuManagementOptions _value )
    {
        DocuManagementOptions docuMgmtOptions = next parmDocuMgmtOptions(_value);
        int num=this.currentTableId();
        if(tableId2Name(num)=="LeaveRequest")
        {this.setupDocuTypescoc();}
        return docuMgmtOptions;
    }

 

    public  void setupDocuTypescoc()
    {
        List            docuTypeList;
        ListIterator    docuTypeListIterator;
        ComboBoxItem    comboxBoxItem;

 

        // Get the list of document types for the primary table
        docuTypeList = DocuUpload::getDocuTypeListcoc();

 

        // Set the list of document types
        this.documentTypes(docuTypeList);

 

        // Initialize the iterator for the list of document types
        docuTypeListIterator = new ListIterator(docuTypeList);

 

        // If the iterator has at least one item, set the selected document type to the first element;
        // otherwise set the selected document to an empty string
        if (docuTypeListIterator.more())
        {
            comboxBoxItem = docuTypeListIterator.value();
            this.selectedDocumentType(comboxBoxItem.parmValue());
        }
        else
        {
            this.selectedDocumentType('');
        }
    }

 

    private static List getDocuTypeListcoc()
    {
        DocuType        docType;
        List            docuTypeList = new List(Types::Class);
        UserInfo        userInfo;

 

        // Get the current language
        select language from userInfo
            where UserInfo.id == curUserId();

 

        // Add all document types that aren't a document library
        while select @TypeId,ActionClassId from docType
            //index TypeIdx
            //where docType.ActionClassId == classNum(DocuActionArchive)
        {
            // If the document type isn't valid, just continue to the next element instead of adding it
            if (DocuEvent::doCheckSkipDocuType(docType))
            {
                continue;
            }

 

            docuTypeList.addEnd(new ComboBoxItem(docType.TypeId, docType.TypeId));
        }

 

        return docuTypeList;
    }

 

}

 

 





Friday, July 11, 2025

Get Mainaccount lookup thorugh lookup code

 Query query = new query();

   QueryBuildDataSource qbds; 
   QueryBuildRange qbr;
   SysTableLookup  sysTableLookup;
   sysTableLookup= SysTableLookup:: newParameters (tableNum (MainAccount),this);
   sysTableLookup.addLookupfield (fieldNum (MainAccount, MainAccountId));
   sysTableLookup.addLookupfield (fieldNum (MainAccount, Name));
   qbds = query.addDataSource(tableNum (MainAccount));
   qbds.orderMode(OrderMode::GroupBy);
   qbds.addGroupByField(fieldNum(MainAccount, MainAccountId));
   qbds.addGroupByField(fieldNum(MainAccount, Name));
   //qbr = qbds.addRange(fieldNum (MainAccount, LedgerChartOfAccounts)); 
   //qbr.value(queryValue (LedgerChartOfAccounts::current()));
   sysTableLookup.parmQuery(query); 
   sysTableLookup.performFormLookup();

Friday, October 4, 2024

Get lookup of All addresses by legal entity

Requirement: I had one Requirement where I wanted to filter the global addresses based on selected legal entity(Company). So by following below code we can get those addresses in lookup which are related to that specific legal entity.


[Form]

public class Form2 extends FormRun

{

    [Control("String")]

    class FormStringControl1

    {

        /// <summary>

        ///

        /// </summary>

        public void lookup()

        {

            Query query = new Query();

            QueryBuildDataSource queryBuildDataSource;

            QueryBuildRange queryBuildRange;

            CompanyInfo  companyInfo;

            OMInternalOrganization  oMInternalOrganization;

            DirOrganizationBase   dirOrganizationBase;

            DirPartyTable dirPartyTable;

            DirPartyLocation DirPartyLocation;

            LogisticsLocation   logisticsLocation;

            LogisticsPostalAddress  logisticsPostalAddress;


            companyInfo=CompanyInfo::findDataArea("USMF");


            select oMInternalOrganization where  oMInternalOrganization.RecId==companyInfo.RecId


                join dirOrganizationBase where dirOrganizationBase.RecId==oMInternalOrganization.RecId


                join  dirPartyTable    where dirPartyTable.RecId==dirOrganizationBase.RecId;



           

 

            SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(LogisticsPostalAddress), this);

 

            sysTableLookup.addLookupField(fieldNum(LogisticsPostalAddress, Address));

            queryBuildDataSource = query.addDataSource(tableNum(LogisticsPostalAddress));

            

            while select  DirPartyLocation where DirPartyLocation.Party==dirPartyTable.RecId


                join logisticsLocation where logisticsLocation.RecId==DirPartyLocation.Location


                join logisticsPostalAddress  where logisticsPostalAddress.Location==logisticsLocation.RecId

           

            {

          

               // Info(strFmt("%1",logisticsPostalAddress.Address));

 

                queryBuildRange = queryBuildDataSource.addRange(fieldNum(LogisticsPostalAddress, RecId));

                queryBuildRange.value(any2Str(logisticsPostalAddress.RecId));


            }

 

            sysTableLookup.parmQuery(query);

 

            sysTableLookup.performFormLookup();


        }


    }


}

Get enumvalues through sql

 Generally in AOT sometimes we can not see tthe basenum values in properties so here is the query which helps  SELECT     EIT.NAME AS EnumNa...