Wednesday, November 28, 2007

Variables in web.config

Web.config

< ?xml version="1.0"?>
...
< appSettings>
< add key="SiteUrl" value="http://dev.site.com/sales"/ >
< add key="ListName" value="Shared Documents"/ >
< /appSettings> 
...
< /system.web >
< /configuration >

Some.aspx.cs

using System.Configuration;

string siteUrl = ConfigurationManager.AppSettings["SiteUrl"];
string listName = ConfigurationManager.AppSettings["ListName"];

Tuesday, November 27, 2007

A callout is a Class Library

A callout is an assembly of type Class Library.

Thursday, November 22, 2007

Adding a folder to a Sharepoint list

From http://blogs.msdn.com/adamhems/archive/2007/08/30/progammatically-adding-folders-to-a-sharepoint-list.aspx

string siteUrl = "http://sample.development.com/sales/prospects";

string listName = "Shared Documents";

SPSite siteCollection = new SPSite(siteUrl);
SPWeb site = siteCollection.OpenWeb();
SPList list = site.Lists[listName];

SPListItem folder = list.Items.Add(list.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, null);

if (folder != null)
{
folder["Name"] = "NameofFolder";
folder.Update();
}

Wednesday, November 21, 2007

Differentiate between contact and account (customerid)

if(opportunity.customerid.type == EntityName.account.ToString())
{
account account = (account)service.Retrieve(EntityName.account.ToString(), opportunity.customerid.Value, new AllColumns());

if(account.revenue != null)
{
opportunity.new_accountvalue = new CrmMoney();
opportunity.new_accountvalue.Value = account.revenue.Value;
}
}
else if(opportunity.customerid.type == EntityName.contact.ToString())
{
contact contact = (contact)service.Retrieve(EntityName.contact.ToString(), opportunity.customerid.Value, new AllColumns());

if(contact.creditlimit != null)
{
opportunity.new_accountvalue = new CrmMoney();
opportunity.new_accountvalue.Value = contact.creditlimit.Value;
}
}

service.Update(opportunity);

Thursday, November 8, 2007

Another Null Reference Exception CRM

Task post create event:

public override void PostCreate(...)
{
Guid opportunityId = task.regardingobjectid.Value;
this.opportunity = (opportunity)service.Retrieve(EntityName.opportunity.ToString(), opportunityId, new AllColumns());

opportunity.new_textfield = "hello world"; // throws a NullReferenceException

string newtext = "hello world";
opportunity.new_textfield = newtext; // works fine
}

Monday, November 5, 2007

CRM Lists links

From
http://sharepointsix.blogspot.com/2007/06/microsoft-crm-30-integrating-crm-into.html

DataGrid Lists
Accounts - http://crm/_root/homepage.aspx?etc=1
Contacts - http://crm/_root/homepage.aspx?etc=2
Opportunities - http://crm/_root/homepage.aspx?etc=3
Leads - http://crm/_root/homepage.aspx?etc=4
Marketing List - http://crm/_root/homepage.aspx?etc=4300
Reports - http://crm/CRMReports/home_reports.aspx
Activities - http://crm/workplace/home_activities.aspx
Calendar - http://crm/workplace/home_calendar.aspx
Articles - http://crm/workplace/home_answers.aspx
Queues - http://crm/workplace/home_workplace.aspx
Competitors - http://crm/_root/homepage.aspx?etc=123
Products - http://crm/_root/homepage.aspx?etc=1024
Sales Literature - http://crm/_root/homepage.aspx?etc=1038
Quotes - http://crm/_root/homepage.aspx?etc=1084
Orders - http://crm/_root/homepage.aspx?etc=1088
Invoices - http://crm/_root/homepage.aspx?etc=1090
Quick Campaigns - http://crm/MA/home_minicamps.aspx
Campaigns - http://crm/MA/home_camps.aspx
Cases - http://crm/CS/home_cases.aspx
Contracts - http://crm/_root/homepage.aspx?etc=1010
Services - http://crm/_root/homepage.aspx?etc=4001

Replace crm for crmdev.mydomain.com or something like that.

Edit:
This links apparently work for the 4.0 version of crm, for example:

Opportunities - http://crm.domain.com/Organization/_root/homepage.aspx?etc=3