Thursday 10 December 2015

Using fiddler to auto respond

Scenario:

We have got something working in Live but not in test environment after the release of new version, we were using the knockout framework on one of the SharePoint portal page. I had to check if the knockout different version is causing issue with our script. In order to quickly see if the same version which we got on live would work against Test environment. I did following

Using Fiddler:

1. Download Fiddler
2. Make a request to the portal Page
3. In fiddler session listing find the script file you like to replace
4. Right click on file and select decode Selected Session
5. On the AutoResponder Tab
  Enable the 'Enable Rules' checkbox
  Enable  the 'Unmatched Requests Pass through' check box

6.  Drag and drop the file to AutoResponder Rule Area
7.  At a bottom under Rule Editor section
Select the second drop down list and select the option of select a file
8. Select the file which you like fiddler to use to mimic response from server by using local file
9. Click Save
10. Refresh page

Monday 26 October 2015

Invalid Action

When trying to browse for CRM org, I started to get following Error


Invalid Action
The selected action was not valid.


When looking into event viewer got following information.


Current key (KeyType : CrmWRPCTokenKey) is expired. This can indicate that a key is not being regenerated correctly. Current Key : CrmKey(Id:4e1d5f40-4d60-e511-a481-00155dc1050c, ScaleGroupId:00000000-0000-0000-0000-000000000000, KeyType:CrmWRPCTokenKey, Expired:True, ValidOn:09/21/2015 10:41:04, ExpiresOn:10/24/2015 10:41:04, CreatedOn:09/21/2015 10:41:04, CreatedBy:<domain>\<domain user name>.




Resolution:
Start the async service (this could be stopped for many reasons, running out of space/performace and developer thought to stop, service was configured to run under user account and the useraccount either expired or disabled and now async service no longer running). Once async service started restart IIS after 5 minutes, so that new generated keys can be used.



Monday 12 October 2015

windows shortcut commands

Windows -> Run

1. inetcpl.cpl : opens internet options

2. iexplore.exe -extoff : opens internet explorer with addons as disabled

3. inetmgr : opens IIS manager

Monday 21 September 2015

Enable-WSManCredSSP : Root element is missing.

 Enable-WSManCredSSP -Role Server

Enable-WSManCredSSP -Role client -DelegateComputer *.<<FQDN e.g kuk.solutions.com>>

Error:
Enable-WSManCredSSP : Root element is missing.




At line:1 char:1

+ Enable-WSManCredSSP -Role client -DelegateComputer *.mydomain.com

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : NotSpecified: (:) [Enable-WSManCredSSP], XmlException

+ FullyQualifiedErrorId : System.Xml.XmlException,Microsoft.WSMan.Management.EnableWSManCredSSPCommand
 
 


Solution applied was to run the script provided in the link below to directly update values.

http://stackoverflow.com/questions/18113651/powershell-remoting-policy-does-not-allow-the-delegation-of-user-credentials


 

Friday 18 September 2015

get crm service users and app pool identitiy and add them to sharepoint

#$SPSiteURL = 'http://lbh.ntlm/sites/rnbtest'
#$GroupName = 'CRM Docs Members '

[CmdletBinding()]
param ([Parameter(Mandatory=$true)] $SPSiteURL,[Parameter(Mandatory=$true)] $GroupName)
$ErrorActionPreference = "Stop"
 

$CRMAPPUsers = Get-WmiObject win32_service | Where-Object{ ($_.Name -like "MSCRMUnzipService") -or ($_.Name -like "MSCRMSandboxService") -or ($_.Name -like 'MSCRMAsyncService$maintenance') -or ($_.Name -like "MSCRMAsyncService") } |%{$_.StartName}|Get-Unique

$CRMAppUser = Get-WmiObject -Class IISApplicationPoolSetting -namespace "root\microsoftiisv2" | Where-Object {$_.Name -like 'W3SVC/APPPOOLS/CRMAppPool'}|%{$_.WAMUserName}
$Users = $CRMAsyncUser , $CRMAPPUsers
$Users = $Users|Get-Unique
if ($ver.Version.Major -gt 1) {$host.Runspace.ThreadOptions = "ReuseThread"}
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$GroupName ='RNBTest Members'
$web = Get-SPWeb -Identity $SPSiteURL
foreach ($User in $Users) {
$User
$web.EnsureUser($User)
$SPUser = get-spuser -web $sPSiteURL|where-object{$_.userlogin -like "*$User*"} |%{$_.Userlogin}

Set-SPUser -UserAlias $SPUser -Web $SPSiteURL -Group $GroupName
#stsadm -o adduser -url $SPSiteURL -userlogin $User -useremail "email@dummy.com" -group $group -username 'dummyusername'
}

Thursday 17 September 2015

Powershell

Pre-Req .Net 4.0 Framework full
http://www.microsoft.com/en-GB/download/details.aspx?id=17851

Download PowerShell V3
http://www.microsoft.com/en-us/download/details.aspx?id=34595


Enable Remoting

To connect to a different machine (or local) and use that's feature e.g. I am logged on to Machine A (my deb box) (no SharePoint installed) and Machine B got SharePoint stuff and I got a task to write PowerShell script add x,y and z user to SharePoint site. The solution is use to remoting instead of logging on to Machine B.


On Machine B write following command
Enable-PSRemoting -Force

On Machine A write following command

Enter-PSSession -ComputerName MachineB -Credential (Get-Credential <domain>/<username>)

now enter SharePoint related command from with in MacihneB like it got SharePoint installed (the commands are executed on remote machine, and PowerShell gets the response with similar objects to work against gets attributes with data but not methods)

Wednesday 26 August 2015

fetch xml to query expression

Some times its easier to get fetch xml using advance find, but then to use it in query expression use the following command, this take fetchxml and then returns the query expression object


var conversionRequest = new Microsoft.Crm.Sdk.Messages.FetchXmlToQueryExpressionRequest


{

FetchXml = fetchXml

};
var conversionResponse =

(Microsoft.Crm.Sdk.Messages.FetchXmlToQueryExpressionResponse)_service.Execute(conversionRequest);

QueryExpression queryExpression = conversionResponse.Query;


 

Thursday 23 July 2015

Creating document library to site using powershell script

Creating document library to site using powershell script

[CmdletBinding()]

param ([Parameter(Mandatory=$true)] $SPSiteURL)

$ErrorActionPreference = "Stop"

[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

function CreateSharePointFolder(

[Parameter(Mandatory=$true)] $SPWeb,

[Parameter(Mandatory=$true)] $ListTemplate,

[Parameter(Mandatory=$true)] $FolderName,

[Parameter(Mandatory=$true)] $Title,

[Parameter(Mandatory=$true)] $Description

)

{

$Folder = $spWeb.Lists.TryGetList($Title)

if($Folder -eq $NULL){

write-host "Creating new Document Library $Title"

$listId = $spWeb.Lists.Add($FolderName,$Description,$listTemplate)

$newList = $spWeb.Lists[$listId]

$newList.Title = $Title

$newList.OnQuickLaunch = "true"

$newList.Update()

}else

{

write-host "$Title already exists"

}

}

$spWeb = Get-SPWeb -Identity $SPSiteURL #http://splocal.ntlm

$listTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary

CreateSharePointFolder -ListTemplate $listTemplate -FolderName "prefix_entityname1" -Title "Entity Display Name1" -Description "Entity description" -SPWeb $spWeb

CreateSharePointFolder -ListTemplate $listTemplate -FolderName "prefix_entityname2" -Title "Entity Display Name2" -Description "Entity description" -SPWeb $spWeb

 


Thursday 16 July 2015

The document records could not be loaded from SharePoint. Try refreshing the grid. If the problem persists, contact your system administrator

One of the project where we were using sharepoint and crm 2011 integration, user was able to see crm list component fine but when he/she tries to upload a document and then try to refresh the grid (using refresh icon on the list component), the document already present where no longer shown and also the whole grids gone blank with following error message

The document records could not be loaded from SharePoint. Try refreshing the grid. If the problem persists, contact your system administrator"


Solution: Make sure

1. User has got the site contributor permission (in this case user had)
2. Execute latest related crm 2011 sharepoint list component  (in this case we already done this)
3. Upload the lastest related crm 2011 sharepoint list component solution file having extension of wsp (this was the error, as we were thinking we had the same version but that wasn't the case), we can check this by downloading the uploaded solution wsp file from sharepoint and then compare it with the latest one ( i normally use beyound compare for this) but normally if there is a differnt you would tell normally by just looking at the file size.

https://community.dynamics.com/crm/f/117/t/141177

Monday 29 June 2015

internet explorer options are disable by network policies enforced

when I try to add a url to trusted sites the page is disabled and I am not able to do so, in order to enable this go to run and write regedit and go to following path and delete the "Internet Settings" sub nodes, and then close and restart internet explorer.
 
HKLM\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings

Thursday 7 May 2015

Shrink Database - SQL JOB that runs every mornign

1. Open "Microsoft SQL Server Management Studio" MSSMS
2 Connect to server
3. In Object explorer expand
     I. Server Instance
     II. SQL Server Agent
     III. Jobs
4. Right click on Jobs folder and click on "New Job..." and provider following information
   I. In General Tab
        a. Name (e.g. Shrink Database)
        b. Description (e.g. Currntly having issue with disk space, setting up the job so that it runs every morning and I don't have to restart box or run sql manually)
  II. In Steps Tab
       a. Click New button
           1. In General Tab
               I. Step name (e.g. SHRINK DATABASE)
               II. Command (e.g. EXEC sp_MSForEachDB 'DBCC SHRINKDATABASE ("?",0)'  )
           2. Advanced Tab
              I. Run as user (e.g. xyz\kaleemkhan)
  III. In Schedules Tab
          a. Name (e.g. Run every morning)
          b. Schedule Type (e.g. Recurring) 
          c. Enable: yes
          d. Frequency: Daily
          e. Recurs: 1 day(s)
          f. Occurs once at 08:00:00
          g. Start date (e.g. creation date)
 

Click Okay to opened windows to setup the SQL job.
     


 

sql for database names created in desc order

I got more than 50 dev crm org, and I created one and forgot which one is the latest one, in order to find that I used following sql it lists all the database names order by created date in desc

SELECT * FROM sys.databases ORDER BY create_date  desc

Thursday 16 April 2015

Show lookup view dialog and Schedule engine

Following is UNSUPPORTED, and was used to work to elemenate some of the user clicks. I had a requirment to select the service on service activity form and then show schedule engine once the service been selected. function PrepoulateService() { if(Xrm.Page.getAttribute(serviceFieldName).getValue()!=null){ return;} var fetchXml = GetServicesQuery(validServices); var data = GetOrganisationService().Fetch(fetchXml); var canCreate = false; Xrm.Page.getAttribute(serviceFieldName).addOnChange(showScheduleEngine); if (data != null && data.length == 1) { if (data[0].attributes.serviceid.value != null) { Xrm.Page.getAttribute(serviceFieldName).setValue(data[0].attributes.serviceid.value); } } else { //select service by showing service lookup document.getElementById(serviceFieldName).click(); } //show schedule engine setTimeout("showScheduleEngine", 500); } function showScheduleEngine() { Type.registerNamespace("Mscrm"); Mscrm.Form_onload = function () { InitCalendar(USER_DATE_FORMATSTRING, USER_DATE_SEPARATOR, USER_DATE_START_DAY, _dCalMinDate); _oServiceRetrieveCommand = new RemoteCommand("Service", "Retrieve"); window.setTimeout("ScheduleActivity($get('crmFormSubmit').crmFormSubmitId.value, ServiceAppointment, !IsNull(location.search.match(/autoSearch=([^&]*)/)))", 100) }; Mscrm.Form_onsave = function (context) { CustomFormSubmit($find("crmForm"), context.getEventArgs()) }; Mscrm.serviceid_onchange = function () { ServiceLookupChanged() }; Mscrm.isalldayevent_onchange = function () { Mscrm.FormControlInputBehavior.GetBehavior("scheduledstart").set_forceSubmit(true); Mscrm.FormControlInputBehavior.GetBehavior("scheduledend").set_forceSubmit(true) } var eventObj = Xrm.Page.ui; var eContext = Mscrm.FormUtility.constructExecutionObject(eventObj, 0, null, null); eContext = Mscrm.FormUtility.constructExecutionObject(eventObj, 0, null, eContext); var t_s = new Date().getTime(); Mscrm.Form_onload(eContext); }

Tuesday 31 March 2015

Refresh all subgrids on a form

RefreshAllSubGrids: function () { Xrm.Page.ui.controls.forEach( function (control, index) { if (control.getControlType() == "subgrid") { control.refresh(); } } ); }