Hi Friends,
i have posted a code here,
function createquote() {
debugger;
try {
if (Xrm.Page.ui.getFormType() == 2) {
var data = new XrmServiceToolkit.Soap.BusinessEntity("sss_quoteapp");
data.attributes["sss_name"] = Xrm.Page.getAttribute("sss_name").getValue();
if (Xrm.Page.getAttribute("sss_account") != null && Xrm.Page.getAttribute("sss_account").getValue() != null) {
var sourceLookup = Xrm.Page.getAttribute("sss_account").getValue();
//get details from source lookup
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = sourceLookup[0].id;
lookupValue[0].name = sourceLookup[0].name;
lookupValue[0].entityType = sourceLookup[0].entityType;
var e = Xrm.Page.getAttribute("sss_account").setValue(lookupValue);
}
var parameters = {};
parameters["sss_name"] = Xrm.Page.getAttribute("sss_name").getValue();
parameters["sss_account"] = Xrm.Page.getAttribute("sss_account").setValue(lookupValue);
var En = 0;
En = XrmServiceToolkit.Soap.Create(data);
Xrm.Utility.openEntityForm("sss_quoteapp", null, parameters);
}
}
catch (e) {
alter(e.message);
}
}
In this i cant able to open the entity form 'quoteapp' , i dont Know where the error occurs .
Suggest a solution.
Thanks & regards
*This post is locked for comments
yes , thanks a lot it works bhuvanesh.
Hi
Did you change the code to
data.attributes["sss_account"].setValue(lookupValue);
as suggested in my previous post?
Did you use
XrmServiceToolkit.Soap.sCreate(data);
Please check the code of XrmServiceToolkit library. Do you have Create or sCreate within Soap object..
(I can see XrmServiceToolkit.Soap.sCreate and XrmServiceToolkit.Rest.createRecord available.
So, check the library code and use the right function.
Thanks a lot for giving suggestion,
But i get this error, while enters into create function,
"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter schemas.microsoft.com/.../Services:request. The InnerException message was 'Error in line 1 position 860. Element 'schemas.datacontract.org/.../System.Collections.Generic:value&; contains data from a type that maps to the name 'www.w3.org/.../XMLSchema:object&;. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name 'object' and namespace 'www.w3.org/.../XMLSchema&;.'. Please see InnerException for more details."
data.attributes["sss_account"]=Xrm.Page.getAttribute("sss_account").setValue(lookupValue);
What is this code means?
As i know (https://msdn.microsoft.com/en-us/library/gg334409.aspx#BKMK_setValue ) setValue(lookupValue)
returns nothing.
I think you wanted to make this:
data.attributes["sss_account"]= lookupValue; Xrm.Page.getAttribute("sss_account").setValue(lookupValue);
Hi
What happens when you use (just this line)
data.attributes["sss_account"].setValue(lookupValue);
Please check the name of the function in XrmServiceToolkit library (it could be sCreate)
Use
XrmServiceToolkit.Soap.sCreate(data);
instead of
XrmServiceToolkit.Soap.Create(data);
But by this code i can get the values and one thing is i can't create entity.
function createquote() {
debugger;
try {
if (Xrm.Page.ui.getFormType() == 2) {
var data = new XrmServiceToolkit.Soap.BusinessEntity("sss_quoteapp");
data.attributes["sss_name"] = Xrm.Page.getAttribute("sss_name").getValue();
if (Xrm.Page.getAttribute("sss_account") != null && Xrm.Page.getAttribute("sss_account").getValue() != null) {
var sourceLookup = Xrm.Page.getAttribute("sss_account").getValue();
//get details from source lookup
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = sourceLookup[0].id;
lookupValue[0].name = sourceLookup[0].name;
lookupValue[0].entityType = sourceLookup[0].entityType;
data.attributes["sss_account"]=
Xrm.Page.getAttribute("sss_account").setValue(lookupValue);
}
var En = 0;
En = XrmServiceToolkit.Soap.Create(data);
Xrm.Utility.openEntityForm("sss_quoteapp", En, e);
}
}
catch (e) {
alter(e.message);
}
}
"Cannot read property 'setValue' of undefined"
This is what i get .
Hi
You have to change the following line:
var e = Xrm.Page.getAttribute("sss_account").setValue(lookupValue);
to
data.attributes["sss_account"].setValue(lookupValue);
You do not need to pass any parameters, as these two values are already available in the record.
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