Change profile based on Client Type

SteveKnottSteveKnott Member Posts: 49
Client wants to use a different role centre / profile (i.e. a heavilly simplified) etc when connecting via phone ( mostly to do approvals ), but have a full profile via the web client. This didnt sound like it would be hard to do... but I am struggling.

Code like the below works on a normal action... but I want it to happen automatically when they open the phone client.
If I subscribe to any of the events in System Initialization or Company triggers - Business Central just "hangs".

I thought perhaps it was a loop - but I dont hit this in the debugger more than once... if I try it in the web, it just gets stuck on "Getting ready".

Appreciate any thoughts or if there is a different / better way ?




local procedure OnCompanyOpenCompleted()
var
ClientTypeManagement: Codeunit "Client Type Management";
ClientType: ClientType;
SessionSettings: SessionSettings;
begin

ClientType := ClientTypeManagement.GetCurrentClientType();
if ClientType = ClientType::Phone then begin
SessionSettings.Init();
if SessionSettings.ProfileId <> 'SALES' then begin
SessionSettings.ProfileId := 'SALES';
SessionSettings.RequestSessionUpdate(false);
end;
end;

end;


Answers

  • markborgesmarkborges Member Posts: 170
    I think a nice approach would be to actually send a link for this user to have on their home screen (or on their browser favorites), to have the full URL for the Web Client that includes the Profile in it.

    Example:
    https://businesscentral.dynamics.com/Production/phone?profile=ACCOUNTANT

    This link forces BC to open the Phone client (even if running from a desktop browser), and it also starts with the ACCOUNTANT profile.

    This way, you could have multiple links to different clients/profiles, and users can add as a link to their home screen, or they can save in notes somewhere.
    Marcelo Borges
    D365 Business Central Solutions Architect
    BC AL/NAV C/AL Developer
    BC Repositories.com
  • SteveKnottSteveKnott Member Posts: 49
    Thanks for the idea.. will give that a try...
Sign In or Register to comment.