How to refresh Quote from Quote Line entity using Client API? - dynamics-crm

I am calling an Web API from Quote Line form through ajax call.
The API is updating Tax field in quote line entity. When i get success response form API, I need to refresh for getting the updated tax data from front end by using this.
Xrm.Page.data.refresh(true).then(successCallBack, errorCallback);
But this updated tax is not being reflected in related sub-grid in Quote entity. If i refresh the browser then i am getting that but i don't want that.
How to do that?
Thanks in advance.

You need to Refresh not only your Record (Quote Line) but also Sub grid (Quote).
You need to use below code snippet in your successCallBackfunction.
I have shown for Contact subgrid but you can updated with your grid name.
function doSomething(executionContext) {
var formContext = executionContext.getFormContext(); // get the form Context
var gridContext = formContext.getControl("Contacts"); // get the grid context Name of gird which you wish to have context of
// Perform operations on the subgrid
gridContext.refresh();
}

Related

How to access to my Grid in Dynamic CRM365 View

I am working on Dynamic CRM365 plugin, in my entity view, I need to know which item has been selected, before I use DOM to detect, however, I can't pass the certification, because all DOM access are risk and need to be replaced, therefore, I checked Xrm.Page.getControl and Xrm.Page.ui.controls, but no luck.
I passed Xrm.Page.getControl("ssl_notesforsigns") or Xrm.Page.getControl("ssl_notesforsign") => return null
I call Xrm.Page.ui, ui = null.
Any idea how to get grid by code?
Thanks
It is good to hear that you no longer want to access the DOM. As you say, that is entirely unsupported.
What is the name of the subgrid on your form? If you go to a form editor and look at the properties for the subgrid, you will see the name (I am guessing that it is not called ssl_notesforsigns). This name is the one you should use, and it can be used when calling Xrm.Page.getControl("namehere") to get your grid context.
Xrm.Page has been deprecated (even though you can still use it). Instead, you should get a reference to your grid context through the execution context. See Client API grid context. For code executing on a form event, you can get your grid context through the form context as follows:
var formContext = executionContext.getFormContext(); // get the form Context
var gridContext = formContext.getControl("namehere"); // get the grid context
When you have a reference to your grid context, you can get the selected rows using getSelectedRows():
var allSelectedRows = gridContext.getGrid().getSelectedRows();

AMChart handleClick to retrieve data from database based on item clicked

I'm using AMChart stacked chart to report test execution status from DB. Php file with query is feed into the dataLoader and the stacked columns displays Pass, Fail and NoRun count data for each category. I'm trying to use handleClick function to make the column clickable and once clicked, a query is fired to retrieve data specific to that column's Pass, Fail or NoRun count data and displays the data on the same page. I'm not sure how to implement this. Any help is greatly appreciated!
Below is all I have so far, clicking the column triggers an alert with name of the category and a count, my goal is to be able to trigger a php file with parameters passed in and display data from DB,
// add click listener
chart.addListener("clickGraphItem", handleClick);
function handleClick(event)
{
alert(event.item.category + ": " + event.item.values.value);
}
The issue has been resolved by using JSON (converted from DB data in PHP) and AJAX to display. Within handleClick I call another JS function and pass in the graph variables that the query inside PHP needs.

Symfony2 form dynamic select entity

I searched for a while, but i didn't find anything.
I want to create a dynamic select with another select. Example :
in my form i have two field (category & subcategory) linked to an entity, when i select an item in category drop-down the item in subcategory will change.
So ok i found i can manage with a event listener.
$builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event){
$form = $event->getForm();
$data = $event->getData();
var_dump($data->getCategory());
});
Ok, i can get the selected category and after load the subcategory, but how i can call this with ajax ?
Hope you have any example...
The response is not so simple... Basically, if you want to build a form according to initial & submitted value, you need to attach an event listener to the PRE_SET_DATA & PRE_SUBMIT event. When the form is initialized, the PRE_SET_DATA event is fired. Here, you will receive your object as data in the form event or null if you don't provide one (Don't forget to handle this case). With this first part, you will be able to build your form dynamically according to your initial data.
Then, when you will handle your form, the PRE_SUBMIT event will be fired if the form is submitted. In this event, you will reveive a flat array wilt all the submitted datas. According to this array, you can rebuild your form according to the submitted datas. The main issue here is the array is an array & not your model object. Meaning you will not have a category object but his view representation (his ID)...
Hope it helps!

Kendo Grid - How to stop or prevent Databound event

I have Kendo grid as empty. Then I add one row, entering values and call saveRow() method. This will call controller and returns message, based on message I want to clear added(newly) record. I have used the code is: grid.dataSource.data([]); this code calling data bound event two times. I want this to be called only ONCE or I don't want to call Data bound event.. but I have to empty the grid.
Please advise.
Hello you can try and use the requestEnd event of the dataSource - check that message which you return, prevent the next dataBinding of the Grid and set the data again to empty array.
e.g.
function onRequestEnd(e){
if()//some condition basedo on the e.response
{
$('#grid').data().kendoGrid.one('dataBinding',function(e){
e.preventDefault();
this.dataSource.data([]);
})
}
}
You could add a filter to your datasource. Make it so that it filters away everything that the server sends it and you should be able to get the behaviour that you are looking for. Then you wont have to mess about with events too much or delete rows manually.
This page contains some info about filtering datasources: kendo datasources
Hope this helps!

Is there any way to set REQUEST using AJAX in Oracle Apex?

This question follows off this previous question.
I have a main report with a column link, that when clicked, refreshes a secondary report with a dynamic action that a) executes JavaScript which calls AJAX to set the page items that the secondary report uses to construct a SQL statement and b) refreshes the report.
There is actually 2 tertiary reports as subregions in the secondary report, conditionally visible only when the REQUEST = a certain value.
I call AJAX to set page items without having to refresh the page using this method:
var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=dummy',&APP_PAGE_ID.);
get.add('PX_ITEM', 'new value');
gReturn = get.get();
get = null;
I was hoping that there would be something as simple as the following to use AJAX to set the REQUEST for that page
get.add('PX_REQUEST', 'new value');
Thank you.

Resources