Source of PrimaryControl (CRM Parameter) - dynamics-crm

In Ribbon Workbench I had created custom button(custom action with help Custom JS Action, so set Crm Parameter like PrimaryControl).
In JS function for example is bottom, we pass formContext and can using API methods.
Pass Customer Engagement data from a page as a parameter to ribbon actions contain info about
To pass in the execution context (form context or grid context) information to JavaScript function for your ribbon actions, specify PrimaryControl for the form context,
Does "PrimaryControl" contains anything else? What is contains other Crm Parameters?
var APP = APP || {};
APP.GetValue = GetValue || {
GetCount: (formContext) => {
formContext.getAttribute("attribute_name");
}
}
Thanks,
Dev Dev

Take a look at this blog, it will give your more idea about crm parameetrs.
In addition if you add debugger to your function and open browser develeoprs tool, you can debug and look more into your PrimaryControl which will be formcontext or executionContext

Related

How to pass parameters to a form using grid's plus button?

I open a new form using the + button of a grid, how do I pass parameters to the new form I open without using the
Xrm.Utility.openEntityForm
or can I use Xrm.Utility.openEntityForm in that case ?
If you are talking about OOB Add New (+) button, then you have to do one of these options:
Either customize that button/command to hook your own javascript action and pass the parameter.
Or hide the OOB button for future backup usage and add a custom button to invoke custom javascript action and pass parameter.
On both cases, custom javascript action will have a library and a method. In that custom javascript method, you can use Xrm.Utility.openEntityForm and pass with needed parameters.
Refer this SO thread
function invokeCustomAddbutton(){
var parameters = {};
parameters["formid"] = "b053a39a-041a-4356-acef-ddf00182762b";
parameters["name"] = "Test";
parameters["telephone1"] = "(425) 555-1234";
Xrm.Utility.openEntityForm("account", null, parameters);
}
You can keep the above method in a js library, and map that in Ribbon command.
Reference

How to navigate using nativescript-urlhandler

I have a javascript Nativescript app (i.e., no Angular, Vue, or typescript), What I want to be able to do is receive a text with a deep-link into my app, receive the link, and then navigate to a specific page.
I've followed the nativescript-urlhandler docs and, on iOS, can receive the url, but I don't know what to do with it once I have it. That is, in my app.js file, I have:
handleOpenURL(function(appURL) {
console.log('Got the following appURL', appURL);
});
What I want to do from here would ordinarily be a
frame.topmost().navigate(navigationOptions);
call, but how can I get the app's viewModel for the resulting page, since that's loaded by main-page.js (using the standard template). That is, such navigation requests are otherwise always made from within the app where the viewModel is already set, but it's not yet set in app.js.
I've been looking for code samples but haven't found anything with straight NativeScript, so I'm posing the question to the StackOverflow-verse. Any help or insight welcome!
I was able to get this working. Yes, the
frame.topmost().navigate(navigationOptions);
works. What I did was create my own instance of the viewModel and set that as the binding context, such as ,
handleOpenURL(function (appUrl) {
var viewModel = createViewModel(); // create own instance of viewModel
viewModel.helpReq = parseUrl(appUrl.toString()); // add data from URL to viewModel
var navigationOptions = {
moduleName: './views/help-req-page',
context: { bindingContext: viewModel }
}
frame.topmost().navigate(navigationOptions);
}
Where parseUrl(), predictably, parses the url and creates an object from the various components.
If I have an empty action bar on the target page, then I automatically get a link back to my app that closes the target page cleanly.
I have this working on iOS; I have not tried Android yet.

How to refresh a BeanFieldGroup after a client request whitout a button?

i hope i will find help here.
Is it possible to refresh a single component in Vaadin.
For example do a client request which change a value [ type = String] inside a single component and refresh this component after it immediate.
Here the content for better understanding:
My Vars:
private static BeanFieldGroup<Service> binder = new BeanFieldGroup<Service>(Service.class);
private FormLayout form = new FormLayout();
My Constructor:
public ServiceDetails()
{
vl = new CssLayout();
vl.addComponent(new Label("Service Details"));
vl.addComponent(form);
vl.setStyleName("details");
vl.setSizeFull();
addPropertyChangeListener(new MyPropertyChangeListener());
refreshBT = new Button("Show Updated Content");
form.addComponent(refreshBT);
addListener();
form.addComponent(binder.buildAndBind("S-ID: ", "id"));
form.addComponent(binder.buildAndBind("Name: ", "name"));
form.addComponent(binder.buildAndBind("Description: ", "description"));
form.addComponent(binder.buildAndBind("Service Tags: ","allTagsOfService"));
form.addComponent(binder.buildAndBind("Attributes: ","allInOnAtt"));
form.addComponent(binder.buildAndBind("Capabilities: ","allInOnCapa"));
form.addComponent(binder.buildAndBind("Categorization: ","allInOnCat"));
form.addComponent(binder.buildAndBind("Relations: ","allInOnRela"));
form.addComponent(binder.buildAndBind("Stakeholder: ","allInOnStkh"));
form.addComponent(binder.buildAndBind("Resources: ","allInOnRes"));
form.addComponent(binder.buildAndBind("Quality: ","quality"));
form.addComponent(binder.buildAndBind("Process: ","process"));
form.addComponent(binder.buildAndBind("Finance: ","finance"));
form.setImmediate(true);
setCompositionRoot(vl);
}
The Button will update the shown content for the user. If a AJAX-request is done the data will be at the server but not shown. If the button is clicked the userview will be updated correctly.
Each variable change call a method which setup my content for the BeanFieldGroup.
public void setService(Service service)
{
setServ(service);
binder.setItemDataSource(getServ());
}
The Problem is now that i need to click this button for a userview refresh, if i clicked on the service inside a canvas structure. By the way this structure is realized in javascript, and a click will always do a AJAX-request [ type = POST] to the server. The send data will be saved correctly in a temporary variable but nothing will be shown at my page. The content change will not be shown to the user page. But this only appear if i use AJAX-requests. If i do click at another component it works without using the button. ):
Any idea how to fix this kind of problem.
Thx for each reply.
When working with http, you have to keep in mind, that the server usually can't inform the client about changes done on server side.
In vaadin, if you modify the UI on server side, outside of the normal "Action from client", then these changes will show up only on the next interaction with the client.
If you need to send the changes from the server to the client, you will have to use a push technology, where the server can inform the client about new/changed content.
Fortunally vaadin includes a easy to use implementation of this push system.
In the Book of Vaadin there is a complete section about server push.
Basically you add the #Push annotation to your UI class and add the required libraries.
You have to keep in mind, that you will need to synchronize access to the UI to get consistent results. (Also documented in the book of vaadin)

SubreportProcessing event handler cannot access my viewmodel due to being on a different thread

I have a WPF application that is utilizing the reporting tools included with Visual Studio 2010. I've had some other problems that I've solved by creating a graph of objects that are all marked as serializable, etc., as mentioned on various other web pages.
The ReportViewer control is contained in a WindowsFormsHost. I'm handling the SubreportProcessing event of the ReportViewer.LocalReport object to provide the data for the sub report.
The object graph that I'm reporting on is generated in my viewmodel, and that viewmodel holds a reference to it. The SubreportProcessing handler is in my code behind of my window (may not be the best place - but I simply want to get the ReportViewer working at this point).
Here's the problem: In my event handler, I'm attempting to get a reference to my viewmodel using the following code:
var vm = DataContext as FailedAssemblyReportViewModel;
When the handler is called, this line throws an InvalidOperationException with the message The calling thread cannot access this object because a different thread owns it.
I didn't realize the handler might be called on a different thread. How can I resolve this?
I attempted some searches, but all I've come up with is in regards to updating the UI from another thread using the Dispatcher, but that won't work in this case...
I solved this problem using something I believe is a hack, by adding the following function:
public object GetDataContext() {
return DataContext;
}
And then replacing the line of code from my question with:
object dc = Dispatcher.Invoke(new Func<object>(GetDataContext), null);
var vm = dc as FailedAssemblyReportViewModel;
However, this seems like a hack, and I might be circumventing some sort of safety check the CLR is doing. Please let me know if this is an incorrect way to accomplish this.
That's a nasty problem you have there.
Why don't you use in the view a content presenter which you bind to a windows form host?
And in the view model you would have a property of type of type WindowsFormsHost. Also,in the view model's constructor you could set the windows form's host Child property with the report viewer.
After that is smooth sailing, you could use your report viewer anywhere in your code. Something like this:
View:
<ContentPresenter Content="{Binding Path=FormHost}"/>
ViewModel:
private ReportViewer report = new ReportViewer();
private WindowsFormsHost host = new WindowsFormsHost();
public WindowsFormsHost FormHost
{
get {return this.host;}
set
{
if(this.host!=value)
{
this.host = value;
OnPropertyChanged("FormHost");
}
}
}
public ViewModel() //constructor
{
this.host.Child = this.report;
}
After that happy coding. Hope it helps.

Extjs MVC - setting up store events in controller

I have a requirement in my application where in I need to show the UI components(like text field, combo box) based on the values i get from the server side. To be precise, I have a combobox on the page, when the user changes the values i need to send the selected value to server to get information on what needs to be displayed. Without using MVC i implemented it as below
When the user changes the value in the combobox, i refresh(using load method) another store
When i get the data back from the server('datachanged' event) i read the data and create the UI components
Now I am trying to use ExtJS MVC, so i have two questions
How do I access a store which is associated to a controller but not necessarily to any UI components from the view
How can I setup the events of a store in the controller(in the control function) just like we setup events from view
Code i want to setup events from Store like 'datachanged' in controller like below -
this.control({
'viewport > #content-panel' : {
render : this.createMainTabs
}
});
In addition to sha's reply I can say that you may setup your store eventhandlers in your controller. For example you have a combobox with a store, so you could write like this:
this.control({
'#myCombo' : {
afterrender : this.setupStoreListeners
}
});
....
setupStoreListeners: function(combo){
var store = combo.store;
store.on('datachanged', //.....);
}
And one more thing, as sha wrote you could always get store by name, but I use this only when I need to share a store instance between multiple controllers. If I need this store only in one controller, I just save it inside this controller:
setupController: function(){
this.myStore = this.getCombo().store; // now you could use this.myStore anywhere you need
}
To get store object in the controller just use this.getStore('StoreName'), each store by default has its own instance and it doesn't really matter whether it's binded to any UI component you have.
After you get store object you can subscribe to any store events using any method you prefer. I usually like
store.on('load', {...})
Also I would not change anything in UI from the view code. I would put all this customization into controller code.

Resources