Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

To atacch map on customise form

Posted on by 1,457
Hi 
I am trying to add map on my form , there is map button in warehouse  from , here there is map button i want to implement same button on my customise form , i created menu item button added the same logic to the button but it is not working .  the property field is same field as warehouse , i and i have use the same menuitem and class on menuitem button in my custom form but the still map is not opening . the menu item button in menuitem is using ths class /LogisticsEntityPostalAddressFormHandler/ shoud i have to make new extension of this class and pass my table buffer to it in main .i will post the main method of this class do i need to customise the main method or do enything else , please guide me ont this , the code is below 
 
 
thanks ,
Dinesh.
  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    To atacch map on customise form
    You said you're getting "your record", but I have no idea what you mean by that. You also told us nothing about what happens when you execute the code. Therefore such information doesn't help us in your effort to help you. If you want our help, you'll need a better job in providing information.
     
    Regarding the question about warehouse, you should use a warehouse ID (InventLocationId) to identify a warehouse. Then call InventLocation::find() to find warehouse record by the ID and use logisticsPostalAddress() to get the warehouse address.
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To atacch map on customise form
    hi , 
    martin,
    I have debugged the code , from here  i am getting my record in code , i have debugged open map method , 
     static void openMap(Args _args)
        {
            LogisticsPostalAddress address;
            LogisticsAddressDateEffectiveMap addressMap;
    
            if (_args.record())
            {
                if (_args.dataset() == tablenum(LogisticsPostalAddress))
                {
                    address = _args.record();
                }
                else if (SysDictTable::isTableMapped(tablenum(LogisticsAddressDateEffectiveMap), _args.dataset()))
                {
                    addressMap = _args.record();
                    address = LogisticsPostalAddress::findByLocation(addressMap.Location);
                }
    
                if (address)
                {
                    DirPartyPostalAddressView::mapIt(address);
                }
            }
        }
       case LogisticsLocationAddressActionButtons::Map :
                        LogisticsPostalAddressFormHandler::openMap(_args);
                        break;
    i am not getting address  , how , i can i fetch  the  address of warehouse if i am selecting the warehouse name on my custom form .
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    To atacch map on customise form
    The address is taken from _args.record(). It seems you've set a wrong value there (so the problem isn't in the code below at all, but in code where you're calling it).
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To atacch map on customise form
    hi martin 
    thanks for reply,
    is it possible to  open the map if i click map button on my form but it will get the address from warehouse form , because both the form are using same invent location id , i will try to debug . 
    thanks 
     
  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    To atacch map on customise form
    Please use the debugger to see where your code fails. There is no universal solution for "it is not working", because that can mean anything.
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    To atacch map on customise form
    the code 
    class LogisticsEntityPostalAddressFormHandler extends LogisticsEntityLocationFormHandler
    {
       /// <summary>
        ///    Called by the menu items form the caller forms not from the Manage Address form.
        /// </summary>
        /// <param name="_args">
        ///    The <c>Args</c> object that is passed from the menu item.
        /// </param>
        /// <param name="_showForm">
        ///    A Boolean value that specifies whether to show the form.
        /// </param>
        public static void main(Args _args, boolean _showForm = true)
        {
            LogisticsEntityPostalAddressFormHandler addressController;
            FormRun         callerForm;
            Object          callerObject;
            Common          callerRecord;
    
            if (_args.parmEnumType() == enumnum(LogisticsLocationAddressActionButtons))
            {
                callerForm = _args.caller();
    
                if (callerForm && formHasMethod(callerForm, identifierstr(getAddressController)))
                {
                    callerObject = callerForm;
                    addressController = callerObject.getAddressController();
                    _args.parmObject(addressController);
                }
    
                switch (_args.parmEnum())
                {
                    case LogisticsLocationAddressActionButtons::New :
                    case LogisticsLocationAddressActionButtons::Edit :
                    case LogisticsLocationAddressActionButtons::Advanced :
                        LogisticsEntityPostalAddressFormHandler::openForm(_args, _showForm);
                        break;
    
                    case LogisticsLocationAddressActionButtons::Delete :
                        addressController.delete();
                        break;
    
                    case LogisticsLocationAddressActionButtons::Deactivate :
                        callerRecord = addressController.getCallerRecord();
                        boolean isDefaultAddress = false;
    
                        EventHandlerResult result = new EventHandlerResult();
    
                        LogisticsEntityPostalAddressFormHandler::getDelegateCaller().checkIsAddressDefault_delegate(callerRecord, addressController.postalAddress(), result);
    
                        if (result.result() != null)
                        {
                            isDefaultAddress = result.result();
                        }
    
                        if(isDefaultAddress)
                        {
                            if (Box::yesNo("@SYS344641", DialogButton::No) == DialogButton::Yes)
                            {
                                addressController.deactivate(callerRecord, true);
                            }
                        }
                        else
                        {
                            addressController.deactivate(callerRecord);
                        }
                        break;
    
                    case LogisticsLocationAddressActionButtons::Map :
                        LogisticsPostalAddressFormHandler::openMap(_args);
                        break;
                }
            }
        }
    }
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans