http://www.powerobjects.com/2013/09/19/dynamics-crm-email-router-troubleshooting-101-outgoing-emails/
Tuesday, 20 December 2016
Wednesday, 26 October 2016
Displaying image for branding site
We got a common site and then branding sites, One of the site wants to show the image before a particular text and other didn't want to show that image at all.
Solution:
Update the common site to have a Div or Span and specify css class on it place this span before the text, e.g.
<span class="summaryimage"></span> Some text is shown here
now in CSS class specify
span.summaryimage{
background: url(http://url of the image) no-repeat 96% 96%;
float: left;
}
Syntax: background: <background-color> | <background-image> | <background-repeat> | <background-attachment> | <background-position>
http://www.htmlgoodies.com/beyond/css/article.php/3868361
Solution:
Update the common site to have a Div or Span and specify css class on it place this span before the text, e.g.
<span class="summaryimage"></span> Some text is shown here
now in CSS class specify
span.summaryimage{
background: url(http://url of the image) no-repeat 96% 96%;
float: left;
}
Syntax: background: <background-color> | <background-image> | <background-repeat> | <background-attachment> | <background-position>
http://www.htmlgoodies.com/beyond/css/article.php/3868361
background-color: white; background-image: url(logo.gif); background-position: 50% 50%; background-repeat: no-repeat; background-attachment: fixed;And change it to this:
background: white url(log.gif) no-repeat fixed 50% 50%;
Friday, 21 October 2016
Revert bad checkin in tfs
Problem:
Preferred (worked for me)
tf rollback /toversion:C<<write your previous changeset number you like to rever to>> /recursive <<path to folder>>
e.g.
tf rollback /toversion:C378 /recursive c:\tfs\dev1\projectxyz
(use . to use the current working space for this)
tf rollback /changeset: <<write your previous changeset number you like to revert to>>
e.g.
When working on one of the project I checked in some wrong code and relaised that I need to rollback to previous version.
Solution:
Right click the folder/file (the one to revert) and click view history and find the last changeset number you like to revert to. Open Visual Studio Command Prompt (Run as administrator) and write the following command
Preferred (worked for me)
tf rollback /toversion:C<<write your previous changeset number you like to rever to>> /recursive <<path to folder>>
e.g.
tf rollback /toversion:C378 /recursive c:\tfs\dev1\projectxyz
(use . to use the current working space for this)
tf rollback /changeset: <<write your previous changeset number you like to revert to>>
e.g.
tf rollback /changeset:378
Friday, 2 September 2016
SQL Management Studio not showing shared/mapped drives in the Restore Database window
I was running out of diskspace and had a databaes .bak file at UNC to restore locally, if I copy that then won't left with enough disk space to restore that as well. When I mapped the shared folder to local drive and tried to restore database I couldn't see mapped drive nor was I able to use share path as is
Reason: SQL management studio run under a different session.
Resolution: In order to use share folder path go to the remote computer and share that folder with everyone (or find which account SQL management studio is running and share it with that account). Then on SQL MS go to restore database option then disk option and click add and then paste the share path in the folder path and in the file name enter the .bak file name and click OK though SQLMS won't show shared drive it will accept the share folder path.
https://blogs.msdn.microsoft.com/sql_scratchpad/2014/03/11/restore-database-from-a-unc-path-why-ssms-doesnt-show-network-drivespaths-in-the-restore-wizard/
Reason: SQL management studio run under a different session.
Resolution: In order to use share folder path go to the remote computer and share that folder with everyone (or find which account SQL management studio is running and share it with that account). Then on SQL MS go to restore database option then disk option and click add and then paste the share path in the folder path and in the file name enter the .bak file name and click OK though SQLMS won't show shared drive it will accept the share folder path.
https://blogs.msdn.microsoft.com/sql_scratchpad/2014/03/11/restore-database-from-a-unc-path-why-ssms-doesnt-show-network-drivespaths-in-the-restore-wizard/
Thursday, 14 July 2016
CRM Tracing/Debugging Service
When writing plugin we try to make sure all possible scenarios are covered however when application is deployed at client side they enter some data which we didn't think of when writing code or use application which causes Business Process error BPE, In this case CRM shows BPE dialog window and use can click on download log button to view the stack trace, sometimes that's not enough, and we should use tracing service so that we can trace to be bit more understandable about which code been executed and with what values been passed by showing including that to trace.
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
then use the Trace method to write trace
tracingService.Trace("Cost provided"+ entityObject.prefix_fieldname);
Now when plugin throws BPE we will get more of an idea about what happened in code.
--
Remote Debugging
Go to google and seach for Remote tools download and install it on the machine which needs to be debugged, if this is a UAT environment within same network where the bug is reported and not able to reproduce locally, Then install it on their. Either to start and stop remote debugger go to start and then select Remote debugger windows app Or else go to windows services area and set the Remote debugger service to run as always.
Run the Remote debugger under local system account.
Depending how the plugin is registered we need to attached to respective process e.g. if the plugin is registered to run under sand box then we need to attach to sandbox process or in case of custom assemblies sandbox async service. If plugin is set to run under full privilege (none/not sandbox) then select w3wp for sync plugin or async service for customer assemblies or async plugins.
To debug with in visual studio go to debug -> attach to process
Attach to : Automatic: Native code (when service to attach is selected then the value might change to Automatic)
on qualifier field click on find and it will discover any remote debuggers running with in local network/subnet, or type manually default to 4016 port
Then trigger the process to debug the code (debug sysmbole won't load initially unless they are triggered an cached first time) if the symbols still doesn't load, then look if there are any more process pending to attached if there are then attached them e.g. w3wp or aysnc service, if this isn't the case cancel attached process and rebuild solution and redeploy and do the attach to process again.
Please note there is default 2 mins time out for Sandbox CRM process to terminate and restart if process take long to process
ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
then use the Trace method to write trace
tracingService.Trace("Cost provided"+ entityObject.prefix_fieldname);
Now when plugin throws BPE we will get more of an idea about what happened in code.
--
Remote Debugging
Go to google and seach for Remote tools download and install it on the machine which needs to be debugged, if this is a UAT environment within same network where the bug is reported and not able to reproduce locally, Then install it on their. Either to start and stop remote debugger go to start and then select Remote debugger windows app Or else go to windows services area and set the Remote debugger service to run as always.
Run the Remote debugger under local system account.
Depending how the plugin is registered we need to attached to respective process e.g. if the plugin is registered to run under sand box then we need to attach to sandbox process or in case of custom assemblies sandbox async service. If plugin is set to run under full privilege (none/not sandbox) then select w3wp for sync plugin or async service for customer assemblies or async plugins.
To debug with in visual studio go to debug -> attach to process
Attach to : Automatic: Native code (when service to attach is selected then the value might change to Automatic)
on qualifier field click on find and it will discover any remote debuggers running with in local network/subnet, or type manually default to 4016 port
Then trigger the process to debug the code (debug sysmbole won't load initially unless they are triggered an cached first time) if the symbols still doesn't load, then look if there are any more process pending to attached if there are then attached them e.g. w3wp or aysnc service, if this isn't the case cancel attached process and rebuild solution and redeploy and do the attach to process again.
Please note there is default 2 mins time out for Sandbox CRM process to terminate and restart if process take long to process
Different ways of doing converting list to custom arrays
List<EntityReference>
list = new List<EntityReference> { new
EntityReference("contact",
Guid.NewGuid()), new
EntityReference("contact",
Guid.NewGuid()) };
Option 1
Entity[] listArray = new Entity[toList.Count];
for (int
i = 0; i < toList.Count; i++)
{
Entity
toParty = new Entity("activityparty");
toParty["partyid"] = toList[i];
listArray[i]
= toParty;
}
Option 2
Entity[] listArray = new Entity[toList.Count];
list.ForEach(delegate(EntityReference
item)
{
Entity
ccParty = new Entity("activityparty");
ccParty["partyid"]
= item;
listArray.SetValue(ccParty,
listArray.Count());
});
Option 3
Entity[] listArray =
ccList.ConvertAll<Entity>(delegate(EntityReference
item) { return new
Entity { LogicalName = "activityparty", Attributes = { { "partyid", item } } }; }).ToArray();
Thursday, 9 June 2016
Compare 2 objects[] in powershell
compare-object command is used to compare two object arrays they can be different types of objects for example an object array from xml compared to object array of csv file data
for my example I used it to compare two different types of crm objects
we use bespoke tool to get crm records with in powershell, but idea here to show the use of compare-object
Compare-object -referenceobject (get-crmrecord -connect http://kuksolutiondev01/org1 -entityname kuk_configurations) -differenceobject (get-crmrecord -connect http://kuksolutiondev02/org4 -entityname kuk_configurations)
Output of above command is like
InputObject SideIndicator
@{Id=7215239d-ddkd-kdld-kdkdfd44c342; Ent... =>
@{Id=7215239d-ddkd-kdld-kdkdkdkf4das; Ent... =>
@{Id=7215fdsf-ddkd-kdld-kdkdfdsa23dkd; Ent... <=
@{Id=72152342-ddkd-kdld-d543fsdakdkd; Ent... =>
@{Id=721523jkl-fdsad-kdk34fdsajkdkdkd; Ent... <=
=> says the difference is found in the http://kuksolutiondev02/org2=4 and <= says difference is in http://kuksolutiondev01/org1
to find the full details of the input object use fl * in the pipeline
Compare-object -referenceobject (get-crmrecord -connect http://kuksolutiondev01/org1 -entityname kuk_configurations) -differenceobject (get-crmrecord -connect http://kuksolutiondev02/org4 -entityname kuk_configurations) | fl *
for my example I used it to compare two different types of crm objects
we use bespoke tool to get crm records with in powershell, but idea here to show the use of compare-object
Compare-object -referenceobject (get-crmrecord -connect http://kuksolutiondev01/org1 -entityname kuk_configurations) -differenceobject (get-crmrecord -connect http://kuksolutiondev02/org4 -entityname kuk_configurations)
Output of above command is like
InputObject SideIndicator
@{Id=7215239d-ddkd-kdld-kdkdfd44c342; Ent... =>
@{Id=7215239d-ddkd-kdld-kdkdkdkf4das; Ent... =>
@{Id=7215fdsf-ddkd-kdld-kdkdfdsa23dkd; Ent... <=
@{Id=72152342-ddkd-kdld-d543fsdakdkd; Ent... =>
@{Id=721523jkl-fdsad-kdk34fdsajkdkdkd; Ent... <=
=> says the difference is found in the http://kuksolutiondev02/org2=4 and <= says difference is in http://kuksolutiondev01/org1
to find the full details of the input object use fl * in the pipeline
Compare-object -referenceobject (get-crmrecord -connect http://kuksolutiondev01/org1 -entityname kuk_configurations) -differenceobject (get-crmrecord -connect http://kuksolutiondev02/org4 -entityname kuk_configurations) | fl *
Thursday, 31 March 2016
allow opening of emails saved in sharepoint to directly open in outlook
Got a client request where they manually upload draft email to SharePoint so that team can work on it to provide extra info, for this they don't like the option to click on email and then get prompt to save the msg file first and then edit it and then manually overwrite it. This takes too much time.
they wanted the email to open directly in outlook/third part client when they click on msg in SharePoint.
$webApp = Get-SPWebApplication "<<web application url>>"
$webApp.AllowedInlineDownloadedMimeTypes.Add("application/msg")
$webApp.Update()
Also add MIME type to web application level i.e. windows -> Run -> InetMgr -> Go to application -> Go to MIME Types and then click Add
Enter
msg to "file name extension" to text field and
"application/vnd.ms-outlook" to text field MIME Types
Do IISReset
https://kerseub.wordpress.com/2012/04/23/add-new-file-type-in-sharepoint/
http://social.technet.microsoft.com/wiki/contents/articles/8073.sharepoint-browser-file-handling-deep-dive.aspx
they wanted the email to open directly in outlook/third part client when they click on msg in SharePoint.
$webApp = Get-SPWebApplication "<<web application url>>"
$webApp.AllowedInlineDownloadedMimeTypes.Add("application/msg")
$webApp.Update()
Also add MIME type to web application level i.e. windows -> Run -> InetMgr -> Go to application -> Go to MIME Types and then click Add
Enter
msg to "file name extension" to text field and
"application/vnd.ms-outlook" to text field MIME Types
Do IISReset
https://kerseub.wordpress.com/2012/04/23/add-new-file-type-in-sharepoint/
http://social.technet.microsoft.com/wiki/contents/articles/8073.sharepoint-browser-file-handling-deep-dive.aspx
Tuesday, 2 February 2016
Check user last login time when user last accessed CRM
http://mscrm-chandan.blogspot.co.uk/2013/04/get-last-log-in-datetime-of-crm-user_30.html
SELECT
SU.SystemUserId
,SU.DomainName
,SU.FullName
,SUO.LastAccessTime
FROM SystemUser SU
INNER JOIN [MSCRM_CONFIG].[dbo].[SystemUserOrganizations] SUO ON SUO.CrmUserId = SU.SystemUserId
INNER JOIN [MSCRM_CONFIG].[dbo].[SystemUserAuthentication] SUA ON SUA.UserId = SUO.UserId
ORDER BY SUO.LastAccessTime DESC,SU.DomainName
SELECT
SU.SystemUserId
,SU.DomainName
,SU.FullName
,SUO.LastAccessTime
FROM SystemUser SU
INNER JOIN [MSCRM_CONFIG].[dbo].[SystemUserOrganizations] SUO ON SUO.CrmUserId = SU.SystemUserId
INNER JOIN [MSCRM_CONFIG].[dbo].[SystemUserAuthentication] SUA ON SUA.UserId = SUO.UserId
ORDER BY SUO.LastAccessTime DESC,SU.DomainName
Friday, 22 January 2016
Thursday, 21 January 2016
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
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.
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
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
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'
}
#$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)
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 =var conversionRequest = new Microsoft.Crm.Sdk.Messages.FetchXmlToQueryExpressionRequest
{
FetchXml = fetchXml
};
(Microsoft.Crm.Sdk.Messages.FetchXmlToQueryExpressionResponse)_service.Execute(conversionRequest);
QueryExpression queryExpression = conversionResponse.Query;
Tuesday, 28 July 2015
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
[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
Subscribe to:
Posts (Atom)