web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Auto choose opportunity form for new opportunities in sales hub

(0) ShareShare
ReportReport
Posted on by Most Valuable Professional

Is there any javascript anyone has that I can use in the onload event of forms to 

- check the app in use i.e. Sales Hub or Project Operations

- If application is Sales Hub, and the opportunity is 'new' / being created, 

Then

Set the form to 'Opportunity'.

Thank you in advance

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi Lewis Baybutt,

    You have two things to check:

    1. The current app is Sales Hub or not.

    2.The Opportunity is new or not.

    For the first thing, it is easy to do. There is a Client API named getCurrentAppName can do this.

    Code:

    function onload(executionContext){
        var globalContext = Xrm.Utility.getGlobalContext();
        globalContext.getCurrentAppName().then(
        function success(result){
            console.log(result);
        },
        function(error){
            consoe.log(error.message)
        }
        );
    }

    For the second, it shouldn't be triggered when the form is load. It should be triggered when you click the 'New' button, correct?

    pastedimage1656057941054v1.png

    If so, you need to override the New button's command by Ribbon Workbench.

    Please refer to this blog:

    How to override out of the box button’s behavior in ms crm – Dynamics 365 CE/Power Platform, PowerApps, Power Automate, Azure by Vishal Grade

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
iampranjal Profile Picture

iampranjal 41

#2
Martin Dráb Profile Picture

Martin Dráb 36 Most Valuable Professional

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans