SetStateKbArticleRequest On CRM 2011 - dynamics-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

Related

MangoPay error on adding bank account to a mango user

I am using the MangoPay php sdk to create a bank account for a user on mango pay, here the code
$api = new \MangoPay\MangoPayApi();
$api->Config->ClientId = 'clientid';
$api->Config->ClientPassword = 'password';
$api->Config->TemporaryFolder = 'temp/mango/';
$mango_user_id = '1234567';
$bank_account = new \MangoPay\BankAccount();
$details = new \MangoPay\BankAccountDetailsIBAN();
$details->IBAN = 'ibanbannkaccountnumber';
$details->BIC = 'CRLYFRPP';
$bank_account->OwnerName = 'Joe Blogs';
$bank_account->Details = $details;
$created_account = $api->Users->CreateBankAccount($mango_user_id,$bank_account);
and getting this error message:
ResponseException in RestTool.php line 345:
Bad request. One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.
https://docs.mangopay.com/endpoints/v2.01/bank-accounts#e41_create-an-iban-bankaccount
OwnerAddress is required
$bank_account->OwnerAddress = new \MangoPay\Address();
$bank_account->OwnerAddress->AddressLine1 = 'addressLine1';
$bank_account->OwnerAddress->City = 'city';
$bank_account->OwnerAddress->PostalCode = 'PostalCode';
$bank_account->OwnerAddress->Country = 'CountryIsoCode';

CRM 2013 to update statecode of Incident Resolution Entity

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);

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)
}
});

Sharepoint 2013 extend ContentBySearchWebpart

My Query in Short :
I extended ContentBySearchWebpart, so that i could create my custom Query for Search. I modified the DataProviderJSON Property and added my custom QueryTemplate in it. But the Webpart renders with default results
What i am trying to do :
I created a catalog site collection and other publishing site collection
Created a List in catalog site, enabled it as catalog, made connection of this catalog in publishing site.
Added CSWP in publishing site Whose Result Source is the above catalog connection.
Now i want to customize my query
I have solved my problem. We are required to set some of the base properties in constructor of our extended webpart. Below is a code sample :
string dataProviderJson = "{{'Properties':{{'TryCache':true,'Scope':'{0}','HHTitle_WB_Marker1':50,'HHTitle_WB_Marker2':60,'UpdateLinksForCatalogItems':true,'EnableStacking':true,'searchTerms':'','Tag':''}},'QueryGroupName':'Default','SourceID':'8413cd39-2156-4e00-b54d-11efd9abdb89','SourceName':'Local SharePoint Results (System)','SourceLevel':'Ssa','CollapseSpecification':'','QueryTemplate':'{{searchTerms?}} (contentclass:sts_listitem OR IsDocument:True) SPSiteUrl:{1} ListId:3d001e7a-d856-428b-9785-edf7ec4f4876 {{?owstaxidMetadataRegion:{{Tag}}}} owstaxIdMetadataRegion:{2}','FallbackSort':[{{'p':'Rank','d':0}}],'RankRules':[],'AsynchronousResultRetrieval':false,'SendContentBeforeQuery':true,'BatchClientQuery':true,'FallbackLanguage':-1,'FallbackRankingModelID':'8f6fd0bc-06f9-43cf-bbab-08c377e083f4','EnableStemming':true,'EnablePhonetic':false,'EnableNicknames':false,'EnableInterleaving':true,'EnableQueryRules':true,'EnableOrderingHitHighlightedProperty':false,'HitHighlightedMultivaluePropertyLimit':-1,'IgnoreContextualScope':false,'ScopeResultsToCurrentSite':false,'TrimDuplicates':true,'ClientType':'ContentSearchRegular','UpdateAjaxNavigate':true,'SummaryLength':180,'DesiredSnippetLength':90,'PersonalizedQuery':false,'FallbackRefinementFilters':null,'IgnoreStaleServerQuery':false,'RenderTemplateId':'DefaultDataProvider','AlternateErrorMessage':null,'Title':''}}";
string siteUrl = SPContext.Current.Site != null ? SPContext.Current.Site.Url.Trim() : "";
base.ResultsPerPage = 3;
base.BypassResultTypes = true;
base.AlwaysRenderOnServer = false;
dataProviderJson = String.Format(dataProviderJson, siteUrl, siteUrl + "/sites/Catalog", "en");
base.DataProviderJSON = dataProviderJson;
base.ItemTemplateId = "/_catalogs/masterpage/Display Templates/Content Web Parts/Banner.js";
base.GroupTemplateId = "/_catalogs/masterpage/Display Templates/Content Web Parts/Group_Content.js";
base.SelectedPropertiesJson = "['PublishingImage','PictureURL','PictureThumbnailURL','Path','Title','Description','SecondaryFileExtension','ContentTypeId']";
base.HitHighlightedPropertiesJson = "['Title','Path','Author','SectionNames','SiteDescription']";
base.QueryGroupName = "Default";
base.RenderTemplateId = "/_catalogs/masterpage/Display Templates/Content Web Parts/Control_Banner.js";
base.StatesJson = "{}";
base.Title = "Banner Search WebPart";
base.Description = "Banner Search WebPart";
base.AllowMinimize = true;
AllowConnect = true;
AllowEdit = true;
AllowHide = true;
base.ZoneID = "ImportedPartZone";

SharePoint 2010 add a new search scope programmatically

You can add a new search scope via powershell:
New-SPEnterpriseSearchQueryScope -SearchApplication "Search Service Application" -Name NewSearchScope -Description "New Search Test Scope" -DisplayInAdminUI 1–OwningSiteUrl http://servername/sites/
But does anyone know of sample code that shows how to do this via OM ? (using the Microsoft.SharePoint.Administration namespace rather than Microsoft.Office.Server.Search)
any pointers will be great
regards
Mo
*Update**
ignoring error handling / logging etc, is this a valid way of doing this:
SPSite siteColl = (SPSite)properties.Feature.Parent;
Microsoft.SharePoint.Administration.SPServiceApplication spserviceapp = siteColl.SearchServiceInstance.Service.Applications["Search Service Application"];
SearchServiceApplication searchserviceapp = (SearchServiceApplication)spserviceapp;
ScopeInfo scopeInfo = new ScopeInfo();
scopeInfo.Name = "Scope test1";
scopeInfo.Description = "Scope test1";
scopeInfo.DisplayInAdminUI = true;
scopeInfo.CompilationType = ScopeCompilationType.AlwaysCompile;
scopeInfo.CompilationState = ScopeCompilationState.NeedsCompile;
int statusCode = 0;
int scopeId = searchserviceapp.AddScope(scopeInfo, out statusCode);
if (scopeId > 0)
{
RuleInfo ruleInfo;
ruleInfo = new RuleInfo();
ruleInfo.FilterBehavior = ScopeRuleFilterBehavior.Include;
ruleInfo.RuleType = ScopeRuleType.AllContent;
int ruleId = searchserviceapp.AddRule(ruleInfo, scopeId);
}
searchserviceapp.Update(true);
rather then the ssp way of searchcontext?
SearchContext searchctx = null;
searchctx = SearchContext.GetContext(web.Site);
Scopes scopes = new Scopes(searchctx);
Scope currentScope = scopes.AllScopes.Create(
"CurrentScopeName", string.Empty, new Uri(web.Site.Url), true,
string.Format("{0}/Search/Pages/Results.aspx", web.Site.Url),
ScopeCompilationType.AlwaysCompile);
currentScope.Update();
currentScope.Rules.CreateUrlRule(ScopeRuleFilterBehavior.Include,
UrlScopeRuleType.Domain, web.Site.Url);
ScopeDisplayGroup group = scopes.GetDisplayGroup(new Uri(web.Url),
"Search Dropdown"); group.Add(currentScope);
group.Update();
scopes.StartCompilation();
scopes.Update();
SearchContext is marked as obsolete in SharePoint 2010 Server, so it is not the recommended way of doing it.
Also, see this answer on SharePoint Overflow.

Resources