Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnInstallAppPerCompany #1881

Closed
bachii1010 opened this issue Mar 29, 2018 · 14 comments

Comments

Projects
None yet
4 participants
@bachii1010
Copy link

commented Mar 29, 2018

Hi

As in the below code when we run the app using F5 or Ctrl + F5 the trigger OnInstallAppPerCompany is not triggering.

image

Please Suggest

Thanks & Regards
Varun Reddy

@waldo1001

This comment has been minimized.

Copy link
Contributor

commented Mar 29, 2018

Just a hunge...

This probably happens because you synchronize (default behaviour), therefore don't install, but upgrade. Add this to your launch.
image
It will remove the previous version first, then actually perform an "install", which will trigger the code.

Note that your data will be wiped every time you deploy from VSCode! So, only necessary when testing your install-codeunit.

@waldo1001

This comment has been minimized.

Copy link
Contributor

commented Mar 29, 2018

I tested this. I have the opposite behavior :-/.

It is always going to run that trigger, no matter what the schemaUpdateMode setting is. #puzzled

Do notice that debugging does not seem to be an option.. . don't know if that is what you are trying to do...

@bachii1010

This comment has been minimized.

Copy link
Author

commented Mar 29, 2018

HI Waldo,

As you suggested i have put recreate in launch.Json but it does not seems to work in that way also the trigger OnInstallAppPerComany is not triggering.

Also is debug not possible for this trigger.

Please suggest?

@kalberes

This comment has been minimized.

Copy link
Contributor

commented Mar 29, 2018

In order to debug, you need code from the web client that triggers it for the moment. We have a backlog item to add more to how debugging works.
The why OnInstallAppPerCompany is not triggering needs investigating

@waldo1001

This comment has been minimized.

Copy link
Contributor

commented Mar 29, 2018

It does trigger on my end though...

@bachii1010

This comment has been minimized.

Copy link
Author

commented Apr 5, 2018

@kalberes i tried to do both ways(debugging and not debugging) but it is not triggering.

Can you please suggest?

@kalberes

This comment has been minimized.

Copy link
Contributor

commented Apr 5, 2018

Hi,
Please specify which versions of the AL extension and server are you using.

@bachii1010

This comment has been minimized.

Copy link
Author

commented Apr 6, 2018

@kalberes i am using March preview update which is 0.15.18771

@kalberes

This comment has been minimized.

Copy link
Contributor

commented Apr 6, 2018

I have submitted a request for the owning team. As soon as there is a response it will be logged here.

@HunterFeltman-MSFT

This comment has been minimized.

Copy link
Member

commented Apr 6, 2018

@bachii1010 I'm afraid I have not been able to reproduce this yet on the March preview you mentioned. Can you provide some sample version of the code you are using in the trigger? Or in the codeunit?

@bachii1010

This comment has been minimized.

Copy link
Author

commented Apr 7, 2018

@HunterFeltman-MSFT i am using the same code as in this document in the below link i additionally kept a message to check if the trigger is running or not.

https://docs.microsoft.com/en-us/dynamics-nav/developer/devenv-extending-application-areas

image

Please suggest

@HunterFeltman-MSFT

This comment has been minimized.

Copy link
Member

commented Apr 7, 2018

I'm not familiar with this particular example code, however, I can tell you that the OnInstallAppPerCompany trigger is going to be run in a UI-less 'background' session and as such will never display messages to users, so unfortunately you would never see things in the client.

If you are sure that the 'IsExampleApplicaitonAreaEnabled' function should be responding back with 'false' then you could check the DB to see if 'EnabledExampleExtension' code has actually executed (though it also seems that there are more 'quit early' checks inside that)

If you want to be really sure, I suggest creating a simple dummy table & page and then populate said table in this code.

for example:

table 50000 TempTable
{
    fields
    {
        field(1;PK; Integer) { }
        field(2;Value; Text[250]) { }
    }
    
    keys
    {
        key(PK; PK) { Clustered = true; }
    }
}

page 50000 TempPage
{
    PageType = Card;
    SourceTable = TempTable;
    
    layout
    {
        area(content)
        {
            group(GroupName)
            {
                field(Value;Value) { ApplicationArea = All; }
            }
        }
    }
}

codeunit 50000 TempCodeunit
{
    Subtype = Install;

    trigger OnInstallAppPerDatabase()
    var
        tempTable : Record TempTable;
    begin
        tempTable.PK := 1;
        tempTable.Value := 'Hello, World!';
        tempTable.Insert();
    end;
}

Note: Use the 'recreate' schemaUpdateMode to assert that data is cleared from this table before you F5 multiple times with this code.

You might have to adjust object ids, but with this you could then navigate directly to your page and see if data was inserted into the table (indicating that the trigger did, in fact, run)
To directly navigate to the page, use a ?page=50000 query string parameter to the webclient URL in your browser

@bachii1010

This comment has been minimized.

Copy link
Author

commented Apr 9, 2018

@HunterFeltman-MSFT thanks for the update yes i tried with your example it is executing i will go into further details what is going wrong with ours.

Thanks once agian!!!!!

@HunterFeltman-MSFT

This comment has been minimized.

Copy link
Member

commented Apr 9, 2018

No problem, thanks for letting us know about the potential issue. Hope you figure out the problem in the ApplicationArea example.

@microsoft microsoft locked and limited conversation to collaborators Jun 9, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.