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
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?
If so, you need to override the New button's command by Ribbon Workbench.
Please refer to this blog:
Adis
136
Super User 2025 Season 1
Sohail Ahmed
81
Jonas "Jones" Melgaard
77
Super User 2025 Season 1