Hi,
I need to create custom dialog popup when clicking a custom Button and adding the products in opportunity product Sub-grid.
So,I have created a custom button.In this Custom button I have written java script function to open a standard look-up window.And it opens for me when Clicking"Look up Records".Like this.
When clicking that button,it open's a MSCRM dialog box like this.
But when I am selecting multiple products and Click "Add" button,the selected products are not added to the grid.Because I have overrrided the Add button feature.
Products not added in the sub grid:
Can we do this by adding products to the product sub grid.I have tried XRMServiceToolkit. Create. method and Associate Method to associate the products.
My JavaScript code is as follows:
function Product()
{
var lookupurl = "/_controls/lookup/lookupinfo.aspx?AllowFilterOff=0&DefaultType=1026&DefaultViewId=BE653221-C406-4DD1-BC80-52EC2420BDBA&DisableQuickFind=0&DisableViewPicker=0&IsInlineMultiLookup=0&LookupStyle=multi&PriceLevelId=%7b3B6B116F-E0E5-E311-AB2D-782BCB14A77B%7d&ShowNewButton=1&ShowPropButton=1&browse=false¤tObjectType=3¤tid=%7b4F64C7CA-E38C-E311-BCD8-782BCB14A77C%7d&dType=1&mrsh=false&objecttypes=1026";
var dialogwindow = new Mscrm.CrmDialog(Mscrm.CrmUri.create(lookupurl), window, 500, 500);
//linked price list url.
var oppid=Xrm.Page.data.entity.getId();
dialogwindow.setCallbackReference(function (result) {
debugger;
alert(oppid);
alert(result.items.length + " records were selected");
var Opportunityproductid = "00000000-0000-0000-0000-000000000000";
for (var i = 0; i < result.items.length; i++) {
alert(result.items[i].typename + " with name " + result.items[i].name + " and id " + result.items[i].id + " was selected in lookup");
var oppproductid = "00000000-0000-0000-0000-000000000000";
var oppproduct = {};
oppproduct.ProductId = "628E42DF-7426-E411-873F-782BCB14A77B";
// used create method to create opportunity product
XrmServiceToolkit.Rest.Create(
oppproduct,
"OpportunityProductSet",
function (result) {
debugger;
alert(result.ProductId);
oppproductid = result.ProductId;
},
function (error) {
debugger;
alert(error.message);
},
false //synchronous call
);
}
});
dialogwindow.show();//showed custom dialog box.
}
Thanks
Arunkumar.V