Hello Team,
here i update the Lookup value in (SalesOrderDetail) Entity Lookup Filed (msdyn_project) it is updated but need to refresh the page after showing value in Lookup Filed i want to need without refresh set the value in Lookup Field
Below my code
SalesOrderDetail objSalesOrderDetailsUpdate = new SalesOrderDetail()
{
Id = contractLineGuid,
msdyn_Project = new EntityReference(msdyn_project.EntityLogicalName, ProjectEntity.Id)
};
//Update the Contract record
currentUserService.Update(objSalesOrderDetailsUpdate);
Hi,
I tried below code and it works as expected -
function OpenContactQC(primaryControl)
{
var formContext=primaryControl;
var entityFormOptions = {};
entityFormOptions["entityName"] = "contact";
entityFormOptions["useQuickCreateForm"] = true;
// Set default values for the Contact form
var formParameters = {};
formParameters["firstname"] = "Sample";
formParameters["lastname"] = "Contact";
formParameters["fullname"] = "Sample Contact";
formParameters["emailaddress1"] = "contact@adventure-works.com";
formParameters["jobtitle"] = "Sr. Marketing Manager";
formParameters["donotemail"] = "1";
formParameters["description"] = "Default values for this record were set programmatically.";
// Open the form.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
function (obj) {
console.log(obj);
console.log("Created new " + obj.savedEntityReference[0].entityType + " named '" + obj.savedEntityReference[0].name + "' with id:" +
obj.savedEntityReference[0].id);
// Create new lookup array
var lookup = [];
lookup[0] = {};
lookup[0].id = obj.savedEntityReference[0].id;
lookup[0].entityType = obj.savedEntityReference[0].entityType;
lookup[0].name = obj.savedEntityReference[0].name;
// Get and Set New Lookup
var emergencyContact = formContext.getAttribute("msft_emergencycontact");
emergencyContact.setValue(lookup);
},
function (error) {
console.log(error);
});
}
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/
Hello Bipin,
here i change my Code and checked but still not working
Old Code
function openDialog()
{
var params = {};
Xrm.Utility.openQuickCreate("msdyn_project", null, params).then(function () { console.log("Success"); }, function (error) {
console.log(error.message);
});
}
New Code
function openDialog() {
var entityFormOptions = {};
entityFormOptions["entityName"] = "msdyn_project";
entityFormOptions["useQuickCreateForm"] = true;
Xrm.Navigation.openForm(entityFormOptions, null).then(
function(lookup) {
console.log("Success");
},
function(error) {
console.log("Error");
}
);
}
Hi,
Xrm.Utility.openQuickCreate is deprecated -
docs.microsoft.com/.../xrm-utility
You should use openForm instead -
docs.microsoft.com/.../openform
So update your code to use openForm and then set the lookup in successCallback method.
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/
Hello Bipin,
i using Below code to opening Quick form using Ribbon
function openDialog()
{
var params = {};
Xrm.Utility.openQuickCreate("msdyn_project", null, params).then(function () { console.log("Success"); }, function (error) {
console.log(error.message);
});
}
HI,
You can set you lookup field using Javascript in successcallback function.
docs.microsoft.com/.../openform
I hope you are using openform method to open quick create form from your ribbon button, if yes then you can easily the lookup with current created record.
successCallback Function No A function to execute when the record is saved in the quick create form.
This function is passed an object as a parameter. The object has a savedEntityReference array with the following properties to identify the record(s) displayed or created:
entityType: The logical name of the table.
id: A string representation of a GUID value for the record.
name: The primary column value of the record displayed or created.
NOTE:
The successCallback function is not executed when you open a form for an existing or new record.
The successCallback function is executed only when you save a record in a quick create form that was opened using the openForm method.
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/
My Plugin Code
if (context.InputParameters.Contains("Target"))
{
BDOContext dbContext = new BDOContext(currentUserService);
Entity ProjectEntity = (Entity)context.InputParameters["Target"];
ProjectEntity.Id = context.PrimaryEntityId;
Guid userId = context.InitiatingUserId;
if (ProjectEntity.Contains("ispl_contractlinenumber"))
{
string ispl_contractlinenumber = (string)ProjectEntity["ispl_contractlinenumber"];
Guid contractLineGuid = Guid.Parse(ispl_contractlinenumber);
SalesOrderDetail objsalesorderdetail = dbContext.SalesOrderDetailSet.Where(c => c.Id == contractLineGuid).FirstOrDefault();
SalesOrderDetail objSalesOrderDetailsUpdate = new SalesOrderDetail()
{
Id = contractLineGuid,
msdyn_Project = new EntityReference(msdyn_project.EntityLogicalName, ProjectEntity.Id)//new EntityReference("msdyn_project", ProjectEntity.Id)
};
//Update the Contract record
currentUserService.Update(objSalesOrderDetailsUpdate);
}
}
Here when i create new create Project button Quick Create Project Form Will open for creating new Project after that when i press save and close that time project will be create
In Parent form one Project field (Lookup) this project will be attached after create.
Now Project is created but not attached automatically in lookup field need to refresh page after attach
Here i attach snap
Hi,
Please share some screenshot of what is happening and what do you want because it is not very clear from your post?
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/
Hello Bipin,
my plugin is already sync mode
Hi,
Change your plugin step to execute in sync mode instead of async to see the result instant.
Please mark my answer verified if this is helpful!
Regards,
Bipin Kumar
Follow my Blog: xrmdynamicscrm.wordpress.com/
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156