Dynamics AX 2009 : can't save new Customer via webservice using AxdCustomer Class - dynamics-ax-2009

CustomerService CustService = new CustomerService();
try
{
CustService.Credentials = new NetworkCredential("xxx", "xxx", "xxx");
AxdCustomer customer = new AxdCustomer();
AxdEntity_CustTable[] table = new AxdEntity_CustTable[1];
AxdEntity_CustTable test = new AxdEntity_CustTable();
test.AccountNum = TextBox1.Text;
test.Name = TextBox1.Text;
test.CustGroup = DropDownList1.SelectedItem.Value;
table[0] = test;
customer.CustTable = table;
CustService.create(customer);
}
catch (Exception ex)
{
err.Visible = true;
lblerr.Text = ex.Message;
}
I am new to Dynamics AX. I'm trying to create a customer which is actually created by consuming a webservice from the web . the above code snippet is the code for that, but it's giving an exception as :
Request Failed. See the Exception Log for details.
I'm not even getting the actual reason why it's not getting created. How to create a customer in dynamics AX 2009 sp1?
Note: CustService is the CustomerService object for the class in CustomerSvc namespace (it is the webservice reference to the CustomerService webservice in Dynamics).

Have a look at the event log in the server where there webservice and the AOS is hosted on.
You may get half a clue from there.
Also have a look at the exception log in AX which you can get from
Basic -> Periodic -> Application Integration framework -> Exceptions
Once you get the error details then you may figure out the problem otherwise post them here and I an have a further look at what the problem might be.

Related

Plaid Link with Java API - Why am I getting 'client_id must be a properly formatted, non-empty string' error

I'm using the official Plaid Java API to make a demo application. I've got the back end working in Sandbox, with their /sandbox/public_token/create generated public keys.
Now, I'm trying to modify the front-end from Plaid's quickstart project to talk with my back end, so I can start using the development tier to work with my IRL bank account.
I'm implementing the basic first step - generating a link_token. However, when the front end calls my controller, I get the following error:
ErrorResponse{displayMessage='null', errorCode='INVALID_FIELD', errorMessage='client_id must be a properly formatted, non-empty string', errorType='INVALID_REQUEST', requestId=''}
This is my current iteration on trying to generate a link_token:
public LinkTokenResponse generateLinkToken() throws IOException {
List<String> plaidProducts = new ArrayList<>();
plaidProducts.add("transactions");
List<String> countryCodes = new ArrayList<>();
countryCodes.add("US");
countryCodes.add("CA");
Response<LinkTokenCreateResponse> response =
plaidService.getClient().service().linkTokenCreate(new LinkTokenCreateRequest(
new LinkTokenCreateRequest.User("test_user_ID"),
"test client",
plaidProducts,
countryCodes,
"en"
).withRedirectUri("")).execute();
try {
ErrorResponse errorResponse = plaidService.getClient().parseError(response);
System.out.println(errorResponse.toString());
} catch (Exception e) {
// deal with it. you didn't even receive a well-formed JSON error response.
}
return new LinkTokenResponse(response.body().getLinkToken());
}
I modeled this after how it seems to work in the Plaid Quickstart's example. I do not see client ID being set explicitly anywhere in there, or anywhere else in Plaid's Java API. I'm at a bit of a loss.
I'm not super familiar with the Java Plaid library specifically, but when using the Plaid client libraries, the client ID is generally set when initializing the client instance. From there, it is automatically included in any calls you make from that client.
You can see the client ID being set in the Java Quickstart here:
https://github.com/plaid/quickstart/blob/master/java/src/main/java/com/plaid/quickstart/QuickstartApplication.java#L67
PlaidClient.Builder builder = PlaidClient.newBuilder()
.clientIdAndSecret(configuration.getPlaidClientID(), configuration.getPlaidSecret());
switch (configuration.getPlaidEnv()) {
case "sandbox":
builder = builder.sandboxBaseUrl();
break;
case "development":
builder = builder.developmentBaseUrl();
break;
case "production":
builder = builder.productionBaseUrl();
break;
default:
throw new IllegalArgumentException("unknown environment: " + configuration.getPlaidEnv());
}
PlaidClient plaidClient = builder.build();

FaultException when using ExecuteTransactionRequest (CRM 2015)

I'm doing a bit of a technical investigation into the ExecuteTransactionRequest. It's not something I've ever used before so I knocked up a very quick experiment just to see how it works. However, when sending off the request the OrganizationService is throwing back a FaultException (below). What I believe is happening is that my version of CRM doesn't support that OrganizationRequest. Although I'm pretty sure I have the right assemblies and version.
Can anyone please shed some light on what I'm missing?
CRM Deployment Version: 7.0.1.129
Organization Version: 7.0.2.53
Microsoft.Xrm Assembly Version: 7.0.0.0 (Also happened with 8.0.0.0)
An unhandled exception of type 'System.ServiceModel.FaultException'
occurred in Microsoft.Xrm.Sdk.dll
Additional information: The formatter threw an exception while trying
to deserialize the message: There was an error while trying to
deserialize parameter
http://schemas.microsoft.com/xrm/2011/Contracts/Services:request. The
InnerException message was 'Error in line 1 position 451. Element
'http://schemas.microsoft.com/xrm/2011/Contracts/Services:request'
contains data from a type that maps to the name
'http://schemas.microsoft.com/xrm/2011/Contracts:ExecuteTransactionRequest'.
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
'ExecuteTransactionRequest' and namespace
'http://schemas.microsoft.com/xrm/2011/Contracts'.'. Please see
InnerException for more details.
CrmConnection connection = CrmConnection.Parse(GetCrmConnectionString("unmanaged"));
IOrganizationService orgService = new OrganizationService(connection);
ExecuteTransactionRequest transactionRequest = new ExecuteTransactionRequest()
{
ReturnResponses = true,
Requests = new OrganizationRequestCollection()
};
Entity newContact = new Entity("contact");
newContact["firstname"] = "Stack";
newContact["lastname"] = "Overflow";
CreateRequest createRequest = new CreateRequest()
{
Target = newContact
};
transactionRequest.Requests.Add(createRequest);
ExecuteTransactionResponse transactionResponse = (ExecuteTransactionResponse)orgService.Execute(transactionRequest);
Update
Quick look at your code, looked like it was because of the CreateRequest not being added to the collection. After your comments and double checking the crm organization version, you are on CRM 2015 (not on update 1). ExecuteTransactionRequest is only supported by CRM 2015 update 1 (version 7.1.XXX) and up (version 8.0.XXX) organizations. So unfortunately, your query won't work until at least the 2015 update is applied to the organization.
You did not add your create request to the ExecuteTransactionRequest - Requests collection. An empty request collection is causing the exceptions most likely.
ExecuteTransactionRequest transactionRequest = new ExecuteTransactionRequest()
{
ReturnResponses = true,
Requests = new OrganizationRequestCollection()
};
Entity newContact = new Entity("contact");
newContact["firstname"] = "Stack";
newContact["lastname"] = "Overflow";
CreateRequest createRequest = new CreateRequest()
{
Target = newContact
};
transactionRequest.Requests.Add(createRequest); //missing
ExecuteTransactionResponse transactionResponse = (ExecuteTransactionResponse)orgService.Execute(transactionRequest);

In MVC, Workflow Service not working wihout any error

I am calling WF as a service (hosted as a Service Reference in client)from my MVC web client. After publish when I deploy and hosting WebClient and WF service in my local machine IIS it is working and workflow calls all the defined activity. But when I am deploying same build on Production Server (Windows Server 2012) then seems WF service not getting called without any error. Please find below code
[HttpPost]
public ActionResult NewFeed(FeedProcessViewmodel fpmodel)
{
//some database object creation and saving
waiting to save the data into database and use the generated request id
sBL.SaveFeedDetailAsync(m_objMasterSnapShot, m_objMasterFeed, m_objFeedDetail);
//calling windows workflow service
InputRequest objInputRequest = new InputRequest { RequestId = "requestid" };
ServiceClient objServiceClient = new ServiceClient();
OutputResponse outputResponse = objServiceClient.SubmitRequest(objInputRequest);
if (!outputResponse.Success)
{
oDic.Add("Error", outputResponse.Message);
jrResult.Data = oDic;
throw new Exception(outputResponse.Message);
}
else
{
//CALLING THIS LINE AFTER OUTRESPONSE LINE EXECUTION
// BUT ALL THE ACTIVITY WITHING WORKFLOW NOT EXECUTED
oDic.Add("Ok", outputResponse.Message);
jrResult.Data = oDic;
}
}
Any help
Thanks
Its too late to reply to this post as I actually forgot to add an update for this.
The reason for above issue was at InputRequest class constructor.
InputRequest objInputRequest = new InputRequest { RequestId = "requestid" };
Had code which was returning null and because InputRequest class had try-catch block, actual error was suppressed and not propagated to calling place.

Push data from a web from into CRM 2015 online

I am trying to create a web from (web application) in Visual Studio 2012 to push data into CRM 2015 online. It keep saying Metadata Contains A Reference That Cannot Be Resolved, when the program tried to call OrgService.
Before that, I create a windows form to do so, it works fine. It can connect to CRM 2015 online and create a new entity record successfully. But when I move the code to Web Application. I does not work.
Code:
private void button1_Click(object sender, EventArgs e)
{
ClientCredentials cre = new ClientCredentials();
cre.UserName.UserName = "MyEmailAddress";
cre.UserName.Password = "Password";
Uri serviceUri = new Uri("https://QA.crm.dynamics.com/XRMServices/2011/Organization.svc");
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, cre, null);//Error occurs here!!!!!!
proxy.EnableProxyTypes();
IOrganizationService service = (IOrganizationService)proxy;
Entity contact = new Entity("contact");
contact["firstname"] = Convert.ToString(firstname.Text);
contact["lastname"] = Convert.ToString(lastname.Text);
contact["emailaddress1"] = Convert.ToString(email.Text);
contact["mobilephone"] = Convert.ToString(phone.Text);
proxy.Create(contact);
}
Error occurs at:
OrganizationServiceProxy proxy = new OrganizationServiceProxy(serviceUri, null, cre, null);
Is there anyone know what is going on here? I appreciate your help.
Thanks.
Try to use following code for initialization of service proxy:
IServiceManagement<IOrganizationService> orgServiceManagement =
ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri("https://democrm.api.crm5.dynamics.com/XRMServices/2011/Organization.svc"));
AuthenticationCredentials authCredentials = new AuthenticationCredentials();
authCredentials.ClientCredentials.UserName.UserName = _userName;
authCredentials.ClientCredentials.UserName.Password = _password;
AuthenticationCredentials tokenCredentials = orgServiceManagement.Authenticate(authCredentials);
IOrganizationService organizationProxy = new OrganizationServiceProxy(orgServiceManagement, tokenCredentials.SecurityTokenResponse);

Updating an Activity in MS CRM via web service?

I've been trying to do this all morning. Anyone have a code snippet (C#) showing how to update an "activity" within CRM via the webservice?
I can CreateReadUpdateDelete with entities, but I'm not sure how to do it with Activities.
Can't find anything on google either...
What are you specifically looking to update? Basically, updating an activity is just like updating any other entity, you just have to use the task entity.
public void CloseTask(CrmService crmsvc, Guid activityid, DateTime start, DateTime end)
{
ColumnSet cols = new ColumnSet();
cols.Attributes = new string[] { "activityid", "statecode" };
task tsk = (task)crmsvc.Retrieve(EntityName.task.ToString(), activityid, cols);
if(tsk.statecode.Value != TaskState.Open)
return;
tsk.actualstart = new CRMDateTime();
tsk.actualstart.value = start.ToString();
tsk.actualend = new CRMDateTime();
tsk.actualend.value = end.ToString();
crmsvc.Update(tsk);
SetStateTaskRequest state = new SetStateTaskRequest();
state.EntityId = activityid;
state.TaskState = TaskState.Completed;
state.TaskStatus = -1; // Let MS CRM decide this property;
SetStateTaskResponse stateSet = (SetStateTaskResponse)crmsvc.Execute(state);
}
Edit: added some sample code. note, I had to modify what I had to strip some proprietary code, so I don't know if this will actually compile. It's close though.
We can also update a Custom Workflow Activity Using Assembly Versioning. Below link gives more information:
http://msdn.microsoft.com/en-us/library/gg328011.aspx

Resources