CRM 2013 to update statecode of Incident Resolution Entity - dynamics-crm-2011

I am quite new to this part of CRM. I want to set the StateCode field of Incident Resolution Entity.
I am trying the following way -
IncidentResolution res = new IncidentResolution();
res.IncidentId = new EntityReference();
res.IncidentId.LogicalName =Incident.EntityLogicalName;
res.IncidentId.Id = new Guid(row["id"].ToString());
res.StateCode = new OptionSetValue((int)IncidentResolutionState.Completed)); //This Following gives the error as System.Nullable<IncidentResolution.StateCode> cannot be assigned to--It is readonly.
CloseIncidentRequest req = new CloseIncidentRequest();
req.IncidentResolution = res;
req.Status = new OptionSetValue();
req.Status.Value = 5; // Problem Solved
service.execute(req);
The problem i am facing is to set the StateCode property for Incident Resolution Entity.
Any help would be appreciated.
Thanks in Advance

you don't need to set the StateCode of the IncidentResolution, only the Status of CloseIncidentRequest:
IncidentResolution res = new IncidentResolution
{
Subject = "Resolved Sample Incident",
IncidentId = new EntityReference(Incident.EntityLogicalName, new Guid(row["id"].ToString()))
};
// Close the incident with the resolution.
CloseIncidentRequest req = new CloseIncidentRequest
{
IncidentResolution = res,
Status = new OptionSetValue(5)
};
service.execute(req);

Related

How do I update NetSuite Department isInactive via WSDL?

I'm trying to update NetSuite Department via WSDL but I'm having an issue updating isInactive. Below is my code in C#:
var record = new com.netsuite.webservices.Department
{
internalId = dp.InternalId,
isInactive = dp.InActive
};
then called
var result = ServiceClient.update(record);
The Department's DEPARTMENT IS INACTIVE on NetSuite doesn't check whether I set it to true or false. What am I doing wrong here?
You forgot to set isInactiveSpecified
Try this:
var record = new com.netsuite.webservices.Department
{
internalId = dp.InternalId,
isInactive = dp.InActive,
isInactiveSpecified = true
};
You need to first .get() the record, set some properties, then .update() the record. Here's what works for me:
var ns = new NetSuite.NetSuiteService();
// passport info skipped
var departmentRef = new RecordRef
{
internalId = "1",
type = RecordType.department,
typeSpecified = true
};
var response = ns.get(departmentRef);
var department = response.record as Department;
department.isInactive = true;
ns.update(department);

Acumatica get Sales Order by Customer Order field

I am attempting to retrieve a single sales order based on the Customer Order field in Acumatica with the Contract Based API. See my code below, which I based off of code in the Contract Based Documentation (page 82).
public SalesOrder GetSalesOrder(string orderNumber)
{
var binding = new System.ServiceModel.BasicHttpBinding()
{
AllowCookies = true,
MaxReceivedMessageSize = 655360,
MaxBufferSize = 655360,
SendTimeout = new TimeSpan(0, 2, 0)
};
var soToBeFound = new SalesOrder()
{
OrderType = new StringValue { Value = "SO" },
CustomerOrder = new StringValue { Value = orderNumber }
};
var address = new System.ServiceModel.EndpointAddress(ConfigurationManager.AppSettings["AcumaticaUrl"]);
using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);
var existingOrder = (SalesOrder)client.Get(soToBeFound);
client.Logout();
return existingOrder;
}
}
When I execute this code I get this exception:
The request channel timed out while waiting for a reply after
00:01:59.9880722. Increase the timeout value passed to the call to
Request or increase the SendTimeout value on the Binding. The time
allotted to this operation may have been a portion of a longer
timeout."
As you can see, I've already increased the timeout to 2 minutes, which seems like forever. Is the Acumatica API really just this slow? Or am I doing something wrong in code?
EDIT:
When I try to get by the "OrderNbr" field instead of "CustomerOrder" field, it works perfectly. Is getting by "CustomerOrder" not allowed in this way? If not, how can I use "CustomerOrder" in a get request?
When you do search via the Contract-Based API, it's required to assign instance of the [FieldType]Search type instead of [FieldType]Value to all fields used in search criteria (StringSearch must be used instead of StringValue in your case):
var soToBeFound = new SalesOrder()
{
OrderType = new StringSearch { Value = "SO" },
CustomerOrder = new StringSearch { Value = orderNumber }
};
Just to confirm, StringSearch is also used in the sample on page 82 from the Contract Based documentation.

Get the object id when the object is created (Parse.com)

I would like to set the string value to the object id when I create the object below. At the moment it prints "nil". Any ideas? Thanks
var date:NSDate = currentDatePicker.date
var DOB:NSDate = DOBPicker.date
var user = PFUser.currentUser()
var report = PFObject(className:"reports")
report["name"] = nameTextField.text
report["DOB"] = DOB
report["date"] = date
report["user"] = user
report.saveInBackground()
var ojId = report.objectId
println(ojId)
saveInBackground is an asynchronous method, so it doesn't wait. The reason why the id is not set is because the entity has not been saved yet.
I think you should use saveInBackgroundWithBlock: and retrieve the object id form within the block (which is executed after the entity has been saved):
var report = PFObject(className:"reports")
report["name"] = nameTextField.text
report["DOB"] = DOB
report["date"] = date
report["user"] = user
report.saveInBackgroundWithBlock { (success, error) -> Void in
if success {
var ojId = report.objectId
println(ojId)
}
}
or maybe also save, which is performed synchronously - but do not use that from the main thread:
report.save()
var ojId = report.objectId
println(ojId)

SetStateKbArticleRequest On CRM 2011

SetStateKbArticleRequest request = new SetStateKbArticleRequest();
request.EntityId = KB_ID;
request.KbArticleState = KbArticleState.Unapproved;
request.KbArticleStatus = 2;
serv.Execute(request);
I'm migrating from crm 4 to 2011 and I am not able to find anything that replaces this feature!
Any help?
You need to use a standard SetStateRequest
SetStateRequest request = new SetStateRequest();
request.State = new OptionSetValue(2); // statecode 2 equals Unapproved
request.Status = new OptionSetValue(2); // statuscode 2 equals Unapproved
request.EntityMoniker = new EntityReference("kbarticle", KB_ID);
SetStateResponse response = (SetStateResponse)serv.Execute(request);
The SetStateKbArticleRequest was replaced by SetStateRequest. See http://msdn.microsoft.com/en-us/library/gg309493.aspx

Set entity record to Active

there are plenty of examples out there of how to set a record to Inactive, but how do you set it to Active?
I'm guessing you just use different values for the State and Status option sets, but what are they?
Thanks!
Example for activating Account entity:
Account account = new Account();
// ...
SetStateRequest req = new SetStateRequest();
req.EntityMoniker = new EntityReference(Account.EntityLogicalName, account.Id);
req.State = new OptionSetValue(0);
req.Status = new OptionSetValue(1);
service.Execute(req);
For status and state codes check Account Entity OptionSet Attribute Metadata on MSDN.
I found the answer.
Just replace the state and status values with the correct values from here:
http://msdn.microsoft.com/en-us/library/bb890228.aspx
This code uses a new thread for the process which isn't always necessary, but you get the idea.
ThreadPool.QueueUserWorkItem(new WaitCallback(SetState), (object)new SetStateThreadRequest()
{
proxy = proxy,
Request = new SetStateRequest()
{
EntityMoniker = new EntityReference(Entity, entity.Id),
State = new OptionSetValue(0), // <== 0 = Active, 1 = Inactive
Status = new OptionSetValue(1) // <== 1 = Active, 2 = Inactive (some use -1)
}
});

Resources