Resolving incidents (closing cases) in CRM4 through webservices? - web-services

I'm trying to resolve/close Dynamics CRM4 cases/incidents through webservices.
A single SetStateIncidentRequest is not enough and returns a Server was unable to process request error message. I think it has something to do with active workflows that trigger on case's attribute changes. I don't know if there's anything else preventing the request to work.
Since it is possible to close those cases through the GUI, I guess there's a "correct" set of steps to follow in order to achieve it through CrmService; unfortunately, I've been googleing it for a while without finding what I want. Could anybody help me, please?

To resolve a case in CRM (in VB.NET), I do the following:
Try
Dim activity As New incidentresolution
Dim closeRequest As New CloseIncidentRequest
Dim closeResponse As New CloseIncidentResponse
Dim strErrors As String = String.Empty()
activity.incidentid = New Lookup
activity.incidentid.type = EntityName.incident.ToString
activity.incidentid.Value = //[GUID OF INCIDENT]
activity.ownerid = New Owner
activity.ownerid.type = EntityName.systemuser.ToString
activity.ownerid.Value = //[GUID OF USER PERFORMING ACTION]
activity.statecode = New IncidentResolutionStateInfo
activity.statecode.Value = 1 //Resolved
activity.statuscode = New Status
activity.statuscode.Value = 5 //Problem Solved
closeRequest.IncidentResolution = activity
closeRequest.Status = 5 //Problem Solved
// IF REQUIRED:
activity.timespent = New CrmNumber
activity.timespent.Value = //[INTEGER REPRESENTING No. OF MIN SPENT ON CASE]
closeResponse = objCrm.Execute(closeRequest)
Catch ex As System.Web.Services.Protocols.SoapException
Dim root As XmlElement = ex.Detail
strErrors = strErrors & vbCrLf & vbCrLf & root.ChildNodes(0).ChildNodes(3).InnerText
Return False
End Try

Here's a tip - catch the SoapException and examine the Detail.OuterXML property and you will get a more detailed error message. It's possible you're not building your request correctly.

Indeed, I didn't know that there exists a CloseIncidentRequest class to use with the CrmService.Execute() method. Most probably the SetStateIncidentRequeset won't work because it's expected that incident resolutions are created that way. Pity that names for classes and actions aren't used consistently (case/incident, resolution/closing)...

Related

GetHostedProfilePage not honouring hostedProfileBillingAddressOptions setting

I've been trying to update our API call to the CIM interface for Authorize.net to hide the Billing Address fields on the hosted profile page.
The documentation states that when call the token creation function, passing in a setting "hostedProfileBillingAddressOptions" with a value of "showNone" will hide the billing address part of the form, however when I pass in this setting I am still getting the billing address showing.
I've verified that I'm passing the setting correctly (added the same way as the "hostedProfileIFrameCommunicatorUrl" and "hostedProfilePageBorderVisible" settings) and if I pass an invalid value for the "hostedProfileBillingAddressOptions" option, the Token creation function will return an error
Is there something else that this option is dependent on, such as an account setting or another settings parameter?
For reference, I'm testing this in the Sandbox system and I'm using the dotNet SDK, my test code for calling the API function is as follows
Public Shared Function CreateHostFormToken(apiId As String, apiKey As String, branchId As Int64, nUser As Contact, iframeComURL As String) As String
Dim nCustProfile = GetCustomerProfile(apiId, apiKey, branchId, nUser)
Dim nHost = New AuthorizeNet.Api.Contracts.V1.getHostedProfilePageRequest()
nHost.customerProfileId = nCustProfile
' Set Auth
Dim nAuth = New Api.Contracts.V1.merchantAuthenticationType()
nAuth.ItemElementName = Api.Contracts.V1.ItemChoiceType.transactionKey
nAuth.name = apiId
nAuth.Item = apiKey
nHost.merchantAuthentication = nAuth
' Set Params
Dim settingList As New List(Of Api.Contracts.V1.settingType)
Dim nParam As New Api.Contracts.V1.settingType With {.settingName = "hostedProfileIFrameCommunicatorUrl",
.settingValue = iframeComURL}
settingList.Add(nParam)
nParam = New Api.Contracts.V1.settingType With {.settingName = "hostedProfilePageBorderVisible",
.settingValue = "false"}
settingList.Add(nParam)
nParam = New Api.Contracts.V1.settingType With {.settingName = "hostedProfileBillingAddressOptions",
.settingValue = "showNone"}
settingList.Add(nParam)
nHost.hostedProfileSettings = settingList.ToArray
Dim nX = New AuthorizeNet.Api.Controllers.getHostedProfilePageController(nHost)
Dim nRes = nX.ExecuteWithApiResponse(GetEnvironment())
Return nRes.token
End Function
I've looked through the SDK code as well, and I don't see anything there that would be preventing the setting from being passed through.
Has anyone come across this issue, or successfully set the card entry form to hide the billing address?
There turned out to be two parts to the solution to this problem:
In order to use the "hostedProfileBillingAddressOptions" option, you need to use a newer version of the capture page than I was using. I was using "https://secure2.authorize.net/profile/", while the new version is "https://secure2.authorize.net/customer/". Added bonus, the new URL provides a much nicer and modern looking form.
However, once this was working, I then had the problem that on entering the card, a validation message told me that "address and Zip code are required", despite not being visible. I did also make sure that I had the option "hostedProfileBillingAddressRequired" set to false (which is it's default value anyway)
The response from Authorize.net support is that in order to capture card without an address, the option "hostedProfileValidationMode" must be set to "testMode".
This is not mentioned in the documentation (at least as far as I could see), so may not be something that other people are aware of since it is a little counter-intuitive to use 'testMode' on a live environment.
It's not ideal since validating the card for a customer account will send a transaction email to the merchant, but it seems there is not another way around this just now.
In summary, to allow the customer to add a credit card to their profile without having to provide an address, you need to specify the following options:
Form URL for capture - https://secure2.authorize.net/customer/
getHostedProfilePageRequest -
hostedProfileIFrameCommunicatorUrl: *your URL*
hostedProfilePageBorderVisible: false //assuming you are using an iFrame
hostedProfileValidationMode: testMode
hostedProfileBillingAddressOptions: showNone

Sharepoint 2013 - Taxonomy- Microsoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession”

I am updating manage meta data field using C#.
Following is code to get TermId for term.
string termId = string.Empty;
try
{
TaxonomySession tSession = TaxonomySession.GetTaxonomySession(CC);
TermStore termStore = taxonomySession.GetDefaultSiteCollectionTermStore();
TermSet tset = ts.GetTermSet(termSetId); // I have proper Guid here, checked this in SharePoint 2013 server.
LabelMatchInformation lmi = new LabelMatchInformation(CC);
lmi.Lcid = 1033;
lmi.TrimUnavailable = true;
lmi.TermLabel = "xyz"; //Name of the term.
TermCollection termMatches = tset.GetTerms(lmi);
CC.Load(tSession);
CC.Load(ts);
CC.Load(tset);
CC.Load(termMatches);
CC.ExecuteQuery();
if (termMatches != null && termMatches.Count() > 0)
termId = termMatches.First().Id.ToString();
}
catch (Exception ex)
{
var d = ex.Message;
}
return termId;
}
But I am getting exception as:
“Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null. \"GetDefaultSiteCollectionTermStore\r\nMicrosoft.SharePoint.Taxonomy.TaxonomySession.GetTaxonomySession”.
I have tried to load manually from Sharepoint2013, it works fine there.
Is there anything missing ?
Thanks for help..
credit to user1545314 and google
Go to the Managed Metadata service (in Service Applications in central admin).
Select Managed Metadata Service Proxy (try clicking the empty space around the text rather than the text itself), and click Properties.
Set that the application is default storage for keywords and for termsets.

MAPI, HrQueryAllRows: Filter messages on subject

I'm pretty much new to MAPI and haven't wrote much C++ Code.
Basically I want to read all emails in the inbox and filter them based on their subject text. So far I'm using the source code provided at the microsoft msdn website which basically reads all emails from the inbox. What I want now is to not get all emails but filter them on the subject, lets say: I want all emails in my Inbox with the subject title "test".
So far I figuered out that the following line of code retrieves all the mails:
hRes = HrQueryAllRows(lpContentsTable, (LPSPropTagArray) &sptCols, &sres, NULL, 0, &pRows);
The parameter &sres is from the type SRestriction.
I tried to implement a filter on 'test' in the subject:
sres.rt = RES_CONTENT;
sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;
sres.res.resContent.ulPropTag = PR_SUBJECT;
sres.res.resContent.lpProp = &SvcProps;
SvcProps.ulPropTag = PR_SUBJECT;
SvcProps.Value.lpszA = "test";
ScvProps is from the type SPropValue.
If i execute the application then I get 0 lines returned. If I change the String test to an empty String then I get all emails.
I'm assuming i'm using the "filter" option wrong, any ideas?
Edit: When I change the FuzzyLevel to:
sres.res.resContent.ulFuzzyLevel = FL_SUBSTRING;
then I can look for subjects that contain a single character but as soon as I add a second character I get 0 rows as result. I'm pretty sure this is just some c++ stuff that I don't understand that causes all this problems ...
I figured the problem out.
Replacing
sres.res.resContent.ulFuzzyLevel = FL_FULLSTRING;
sres.res.resContent.ulPropTag = PR_SUBJECT;
SvcProps.ulPropTag = PR_SUBJECT;
with
sres.res.resContent.ulFuzzyLevel = FL_SUBSTRING;
sres.res.resContent.ulPropTag = PR_SUBJECT_A;
SvcProps.ulPropTag = PR_SUBJECT_A;
fixed the problem.

Start workflow with web services Sharepoint 2010

I am attempting to run a visual studio sequential workflow on items in a library, but have hit a wall. since the client object model doesn't seem to support starting workflows, I am attempting to use the web service call to "../_vti_bin/workflow.asmx" web service.
Everything seems ok up to the point where it calls
StartWorkflow(item, templateid, workflowParameters)
I get an error saying parameters can't be null. My workflow has no init form, so im not sure what params to pass. can someone help me out here?
here is my code:
Private Sub LoadDataFromSite()
Try
Dim frm As New DateForm
frm.ShowDialog()
fromDate = frm.DateTimePicker1.Value.Date
toDate = frm.DateTimePicker2.Value.Date
Dim siteUrl As String = "http://host.dom.local/payroll/"
Dim clientContext As New ClientOM.ClientContext(siteUrl)
Dim oList As ClientOM.List = clientContext.Web.Lists.GetByTitle("Timesheets")
Dim oListItem As ListItem
Dim camlQuery As New ClientOM.CamlQuery()
camlQuery.ViewXml = "<View/>"
Dim collListItem As ClientOM.ListItemCollection = oList.GetItems(camlQuery)
clientContext.Load(collListItem)
clientContext.ExecuteQuery()
For Each oListItem In collListItem
Console.WriteLine("ID: {0} " & vbCrLf & "Title: {1} " & vbCrLf & "", oListItem.Id, oListItem("Title"))
If CDate(oListItem("Timesheet_x0020_Date")).Date >= fromDate And _
CDate(oListItem("Timesheet_x0020_Date")).Date <= toDate Then
MsgBox("found a timesheet in the specified date range = " & oListItem("Timesheet_x0020_Date"))
Dim sguid As String = "{2009B982-3A49-4217-99AC-7E52C0EE44EF}"
Dim workflowTemplateGuid As New Guid(sguid)
Dim _itemURI As String = "http://host.dom.local/payroll/" & oListItem("Title")
Dim workflow As WSWorkflow.Workflow = New WSWorkflow.Workflow
workflow.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
workflow.StartWorkflow(_itemURI, workflowTemplateGuid, Nothing)
End If
Next oListItem
Catch exs As Microsoft.SharePoint.Client.ServerException
MsgBox("Error starting export workflow on list items. It may not be finished yet, and you may need to export the timesheets manually." & exs.Message)
Catch exss As Microsoft.SharePoint.Client.ClientRequestException
MsgBox("Error starting export workflow on list items. It may not be finished yet, and you may need to export the timesheets manually." & exss.Message)
Catch ext As Microsoft.SharePoint.SoapServer.SoapServerException
MsgBox("Error starting export workflow on list items. Soap exception. " & ext.Message)
End Try
End Sub
so I can't pass NOTHING to the function call, so what do here?
There are two problems with your code.
1) Item URI/URL - its should be ows_EncodedAbsUrl of Item, you can get it from Lists.asmx
2) association data - can not be null.
you can find detailed explanation at.
http://sharepointbuzzer.com/2013/10/15/start-workflow-using-client-object-model/
I hope it solves your error.

Unable to access WMI on remote machine using vb.net

I've had a scout around and can't seem to find the answer anywhere, so need to ask.
I'm trying to query the WMI on a remote machine, but I need to do so as the admin account and I'm having problems doing so.
The code I am using is:
Public Sub OperatingSystem(ByVal computeritem As String)
'set Username and Password which system will access the network with.
Dim options As ConnectionOptions
options = New ConnectionOptions()
options.Authority = "ntdlmdomain:" & ipaddress
options.Username = "Username"
options.Password = "Password"
scope = New ManagementScope("\\" & ipaddress & "\root\cimv2", options)
scope.Connect()
Dim query As ObjectQuery
query = New ObjectQuery("SELECT * FROM Win32_OperatingSystem")
Dim searcher As ManagementObjectSearcher
searcher = New ManagementObjectSearcher(scope, query)
the query continues to go and pull all kinds of information through to a spradsheet.. well it would if it worked!
The line of code that is falling over is:
scope = New ManagementScope("\\" & ipaddress & "\root\cimv2", options)
scope.Connect()
It's giving me an error message that just says 'Invalid parameter'. When I go to view detail, there's nothing in inner exception and the only thing that I can see of any value is ErrorCode:ManagementStatus.InvalidParameter
I apologize if this is something really simple.. I am still fairly new to this but if someone could give me some guidance that would really be appreciated.
Many Thanks.
It looks like the reference to ipaddress is not initialized. Since computeritem is passed as a parameter to the sub, your code might work better with:
scope = New ManagementScope("\\" & computeritem & "\root\cimv2", options)