Class Web
The Web
class is the basic building block for your custom CRM Application Extension in .NET.
The Web
class contains methods to add content to your CRM web page.
- Inheritance
-
Web
- Derived
- Inherited Members
Constructors
Web()
Fields
_modeDefault
This is the mode that will be set when Dispatch.EitherField("HiddenMode") return blank. The default value for this property is Mode.View. The specialized class should set this value on the constructor.
Field Value
Properties
BeenThere
Use this to set/check if the page is being redisplayed from content.
Property Value
Remarks
Boolean True/False depending on whether this page is being refreshed from content or not.
ContentIdField
The name of the field within content or query fields that holds the id.
Property Value
CurrentUser
Use this to get information about the currently logged on user. See Sage.CRM.Utils.UserSession class for more details.
Property Value
Dispatch
Use this for controlling database transactions and getting locks. Also gives access to Cookies and Content and Query fields.
Property Value
EntityName
This should be set to the name of the entity that is being used on this page, if applicable.
Property Value
HTML
HTMLBuilder object to access HTML builder methods.
Property Value
IdField
The name of the field on the table that holds the ID value.
Property Value
Keys
Gets the Keys object with information about the current context.
Property Value
Metadata
Use this to access metadata e.g. screens, lists, translations etc. See Sage.CRM.Utils.Metadata for details.
Property Value
Mode
Use this property to get/set the mode of the current page.
Property Value
- See Also
OnLoad
Sets the OnLoad Javascript event for the page (writeonly).
Property Value
OnUnLoad
Sets the OnUnload Javascript event for the page (writeonly).
Property Value
ThisDotNetDll
The name of the .NET Dll that this method is in (readonly). Used to redirect to same Dll or to a different method within the same dll.
Property Value
ThisDotNetFunction
The name of the .NET entry point method that was called to generate the current page (readonly).
Property Value
Methods
AddButtonContent(string)
Add a HTML string to the section of page underneath the buttons.
Parameters
content
stringHTML to be added.
AddConfirmButton(string, string, string, string, string)
Adds a button that asks the user for confirmation before inserting a value into a content field and then submitting the form.
public void AddConfirmButton(string caption, string image, string question, string fieldName, string fieldValue)
Parameters
caption
stringCaption for the button (will be translated with Button family).
image
stringImage for the button (must exist in img\button folder).
question
stringText of question to show to user in alert box.
fieldName
stringName of any field that has been added within the <FORM> tag
fieldValue
stringValue to set into the field before submitting the form
AddConfirmButton(string, string, string)
Adds a button that asks the user for confirmation before submitting a form.
Parameters
caption
stringCaption for the button (will be translated with Button family).
image
stringImage for the button (must exist in img\button folder).
question
stringText of question to show to the user in an alert box.
AddContent(UIObject)
Add one UIObject to the page content that will be displayed to user. This is the main method used to display query results to the user.
Parameters
value
UIObjectUIObject to be added to the page.
AddContent(string, string)
This an overload of AddContent to display the HTML text with a specified style applied. Style can be any style from the CRM style sheet (Sage.Styles).
Parameters
contentString
stringAny HTML string to be added to the page.
crmStyle
stringAny CRM style to apply to the content (see Sage.Styles for full list).
AddContent(string)
Add a string of HTML text to the page content that will be displayed to user.
Parameters
contentString
stringAny HTML string to be added to the page.
AddError(string)
Adds a HTML string to the error content. Any strings added here will be displayed in a red banner at the top of the page.
Parameters
errorString
stringThe error string to be added.
Examples
AddError("Validation failed, please re-enter details");
AddHeaderContent(string)
Adds HTML content to the <BODY> tag. This HTML content will be added to the page before any content that is added with AddContent.
Parameters
content
stringHTML string to be added.
AddHeaderScript(string)
Adds Javascript to the <SCRIPT> section of the page.
Parameters
script
stringValid Javascript.
AddHelpButton(string, bool, bool)
Adds a help button to the page.
Parameters
aHelpFile
stringHelp file name.
aUseCaption
boolShow help caption.
aSmallButton
boolShow small button.
AddHelpButton(string)
Adds a help button to the set of buttons on a page.
Parameters
sFileName
stringThe fully qualified name of the help file e.g. "/Main Menu/wwhelp/wwhimpl/js/html/wwhelp.htm?href=AddingInformation.html". the install name will be pre-pended to this.
AddInfo(string)
Adds text to the "Info Content" of the page. The Info Content is text that is displayed in a blue line at the top of the page.
Parameters
infoString
stringThe text to be added.
Examples
AddInfo("This company cannot be deleted");
AddSubmitButton(string, string, string, string)
Adds a button that inserts a value into a content field and submits a form.
Parameters
caption
stringCaption for the button. This will be translated with the Button family.
image
stringThe name of the image file to use for the button. The file must reside in the img\buttons folder of the install.
fieldName
stringName of any field that has been added within the <FORM> tag.
fieldValue
stringValue to set into the field before submitting the form.
AddSubmitButton(string, string, string)
Adds a submit button to the list of buttons on the page.
Parameters
caption
stringCaption for the button. This will be translated with the Button family.
image
stringThe name of the image file to use for the button. The file must reside in the img\buttons folder of the install.
onSubmit
stringJavascript that is to run in the onSubmit event of the button.
AddTabHead(string)
Adds a heading where the tabs usually appear.
Parameters
Caption
stringCaption to be shown.
AddToHeader(string)
Adds HTML content to the <HEAD> section of the page.
Parameters
html
stringHTML string to be added.
AddTopContent(UIObject)
Adds HTML to the top content section of the CRM page.
Parameters
value
UIObjectAn UIObject to be added to the top content area.
AddTopContent(string)
Adds HTML to the top content section of the CRM page.
Parameters
topString
stringHTML to be added to the top content.
AddUrlButton(string, string, string)
Add a URL button to the list of buttons on the page. When the button is clicked the page location is set to the URL.
Parameters
caption
stringCaption for the button. This will be translated with the Button family.
image
stringThe name of the image file to use for the button. The file must reside in the img\buttons folder of the install.
url
stringThe URL to go to when the button is clicked.
AddWorkflowButtons(string)
Adds workflow buttons for an entity to the the page.
Parameters
entityName
stringEntity name for which to display buttons.
BuildContents()
This is the main method that is used to create a web page. Override this to build your own page. The main function of this method is to use the AddContent() method to build up the HTML that creates the screen that is shown to the user.
Content(string)
Get the value for a field from the query fields or the content fields. Queryfields are checked first.
Parameters
fieldName
stringThe fieldname whose value to return.
Returns
- string
The value in the field. If the field is not found then a blank string.
CreateAppointment()
Creates a new appointment object. User can fill in details and click Save to create a new appointment on the calendar. Note appointments should be used for communications that have more than one user.
Returns
- Communication
Entity CommunicationEntity.
CreateEntity(string)
Creates an instance of an Entity object that can be used to insert a new entity.
Parameters
entityName
stringThe name of the entity that you want to create.
Returns
- Entity
An Entity object.
CreateRecord(string, string)
Creates an instance of a Record object that can be used to insert a new record to a table in an external database.
[Obsolete("Use: new Record(tableName, machineName)")]
public Record CreateRecord(string tableName, string machineName)
Parameters
Returns
- Record
A Record object.
CreateRecord(string)
Creates an instance of a Record object that can be used to insert a new record to a table.
Parameters
tableName
stringTable Name.
Returns
- Record
A Record object.
CreateTask()
Creates a new Task object. The user can fill in details and click Save to create a new task on the calendar.
Returns
- Communication
Entity CommunicationEntity.
DontAddToHistory()
When this is invoked the current page will not be added to the history.
FindCurrentEntity(string)
Returns an Entity object representing the current record if applicable.
Parameters
entityName
string
Returns
- Entity
An Entity object
FindCurrentRecord(string)
Returns a record object for the current record. It retrieves the current record based on the current context.
Parameters
tableName
string
Returns
- Record
A Record object.
FindEntity(string, string, string)
Returns an Entity Object and record(s) for the specified entity. This can be used to update records.
Parameters
Returns
- Entity
An Entity object.
FindRecord(string, string)
Returns a Record object representing the record or records specified by the WHERE clause given, within the specified table.
Parameters
tableName
stringTable name to select from.
whereClause
stringValid SQL WHERE clause to use to select record or records.
Returns
- Record
A Record object.
GetBlock(string)
Creates a Sage CRM block object.
Parameters
blockName
stringThe name of the block to retrieve. Standard system Block Names include the following = "marquee","message","file","graphic","chart","pipeline","orgChart". In a custom Dll you could choose to send in an alternate name if you know that the block exists.
Returns
- Sage
Crm Block A SageCrmBlock object.
GetChartGraphicBlock()
Creates a blank Chart Graphic Block. A Chart Graphic Block inherits all the capabilities of the Graphics Block and adds to it the ability to generate a variety of different charts. These charts may be based on data retrieved via SQL or added through ASP for their values. In this way, they can be fully dynamic and represent data at a specific moment in time.
Returns
- Chart
Graphic Block SageCrmChartGraphicBlock object.
GetChartGraphicBlock(string)
Creates a Chart Graphic Block that has already been configured in the CRM interface through Admin | Customization. A Chart Graphic Block inherits all the capabilities of the Graphics Block and adds to it the ability to generate a variety of different charts. These charts may depend on data retrieved via SQL or added through ASP for their values. In this way, they can be fully dynamic and represent data at a specific moment in time.
[Obsolete("Use: new ChartGraphicBlock(string)")]
public ChartGraphicBlock GetChartGraphicBlock(string blockName)
Parameters
blockName
string
Returns
- Chart
Graphic Block SageCrmChartGraphicBlock object.
GetContextInfo(string, string)
Returns a field value for a given entity name and field name in the current context.
Parameters
context
stringName of any main entity within CRM.
fieldname
stringName of any field that exists on the entity.
Returns
- string
The value of that field in the current context.
GetContextInfo(string)
Returns the current ID (based on the current context) of the given entity.
Parameters
context
stringName of any main entity within CRM.
Returns
- string
The ID of the entity.
GetCustomEntityTopFrame(string)
Returns the HTML for top content based on the entity name passed in.
Parameters
sEntityName
string
Returns
GetFileBlock()
Get a blank File Block A File Block object provides access to external files that are not part of the system. It allows these files to appear as if they are part of the system and to be called upon using ASP in the same way as any other CRM page. Note that the files need to be formatted for HTML appearance. If you don't specify where the file is stored in the directory path property, the system looks for the file in the CRM Reports directory.
Returns
GetFileBlock(string)
Creates a File Block that has already been configured in Admin | Customization. A File Block object provides access to external files that are not part of the system. It allows these files to appear as if they are part of the system and to be called upon using ASP in the same way as any other CRM page. Note that the files need to be formatted for HTML appearance. If you don't specify where the file is stored in the directory path property, the system looks for the file in the CRM Reports directory.
Parameters
blockName
string
Returns
GetGraphicBlock()
Creates a blank Graphic Block. A Graphic Block enables the display of images through an ASP page. It is more powerful than standard static images, as variables can be used in their creation. These variables may represent live data from a database or incorporate details of the current user, such as theirprivileges or settings.
Returns
- Graphic
Block SageCrmGraphicBlock object
GetGraphicBlock(string)
Creates a Graphic Block that has already been configured in Admin | Customization. A Graphic Block enables the display of images through an ASP page. It is more powerful than standard static images, as variables can be used in their creation. These variables may represent live data from a database or incorporate details of the current user, such as theirprivileges or settings.
[Obsolete("Use: new GraphicBlock(blockName)")]
public GraphicBlock GetGraphicBlock(string blockName)
Parameters
blockName
string
Returns
- Graphic
Block SageCrmGraphicBlock object
GetHelpButton(string, bool, bool)
Returns the HTML String for a help button.
Parameters
aHelpFile
stringHelp file name.
aUseCaption
boolShow help caption.
aSmallButton
boolShow small button.
Returns
- string
HTML string.
GetHelpButton(string)
Returns the HTML String for a help button.
Parameters
sFileName
stringHelp file name.
Returns
- string
HTML String.
GetJsString(string)
Transforms a string into a safe string to use in Javascript, escaping all neccessary characters.
Parameters
inString
stringString to transform.
Returns
- string
String with characters escaped.
GetKeys()
Obsolete, see Sage.CRM.Utils.Keys instead.
Returns
GetMarqueeBlock()
Creates a blank Marquee Block. A Marquee Block adds scrolling text to a page. The content of the text is maintained through Administration | Customization | Translations. You can use the properties of this block to control the direction, speed, and style of the scrolling text.
Returns
GetMarqueeBlock(string)
Creates a Marquee Block that has already been configured in Admin | Customization. A Marquee Block adds scrolling text to a page. The content of the text is maintained through Administration | Customization | Translations. You can use the properties of this block to control the direction, speed, and style of the scrolling text.
[Obsolete("Use: new MarqueeBlock(blockName)")]
public MarqueeBlock GetMarqueeBlock(string blockName)
Parameters
blockName
string
Returns
GetMessageBlock()
Creates a blank Message Block. A Message Block allows you to send messages in e-mail and SMS format. Include this block in ASP pages to display a simple e-mail form or to automate the message sending in response to a certain event.
Returns
GetMessageBlock(string)
Creates a Message Block that has already been configured in Admin | Customization. A Message Block allows you to send messages in e-mail and SMS format. Include this block in ASP pages to display a simple e-mail form or to automate the message sending in response to a certain event.
[Obsolete("Use: new MessageBlock(blockName)")]
public MessageBlock GetMessageBlock(string blockName)
Parameters
blockName
string
Returns
GetNextId(string, string, string, string, string, string)
Retrieves the next ID for a table in another database.
public int GetNextId(string tableName, string driver, string server, string databaseName, string userName, string password)
Parameters
Returns
- int
The next ID value.
GetNextId(string)
Retrieves the next ID for a table.
Parameters
tableName
stringThe table for which to get the next ID. Must be a standard CRM table within the CRM database.
Returns
- int
The next ID value.
GetOrgGraphicBlock()
Creates a blank Org-chart Graphic Block. The organizational graphic is an implementation of the Graphic Block that is used for organizational charting. These diagrams can be drawn from data supplied to them from an ASP page or from data stored in a table. Other parameters can also be set to describe the look of the diagram. The most common use of these diagrams is to display an employee hierarchy for a company. Currently, all the parameters and data are set through the 'OrgTree' command. As with the Graphics Block, the organizational graphic is recreated every time it is requested and can therefore be based on real time data.
Returns
- Org
Graphic Block SageCrmOrgGraphicBlock object.
GetOrgGraphicBlock(string)
Creates an Org chart Graphic Block that has already been configured in Admin | Customization The organizational graphic is an implementation of the Graphic Block that is used for organizational charting. These diagrams can be drawn from data supplied to them from an ASP page or from data stored in a table. Other parameters can also be set to describe the look of the diagram. The most common use of these diagrams is to display an employee hierarchy for a company. Currently, all the parameters and data are set through the 'OrgTree' command. As with the Graphics Block, the organizational graphic is recreated every time it is requested and can therefore be based on real time data.
[Obsolete("Use: new OrgGraphicBlock(blockName)")]
public OrgGraphicBlock GetOrgGraphicBlock(string blockName)
Parameters
blockName
string
Returns
- Org
Graphic Block SageCrmOrgGraphicBlock object.
GetPipelineGraphicBlock()
Creates a blank Pipeline Graphic Block. The pipeline graphic is an implementation of the Graphic Block that includes extra functionality. You use the Pipeline Graphic to create cross-sectional diagrams that can represent data from an ASP page or data from a table. You use the parameters of this block to change the look and feel of the pipeline. You can customize individual sections of the pipeline graphic to appear differently as the user selects them (by clicking on them). Similar to the Graphics Block, the Pipeline graphic is recreated every time it is requested and can therefore be based on real time data. It can also use all of the features of the Graphics Block. The default size of the image created by the pipeline is set at 600 pixels wide and 100 in height, however it can be changed using the Graphics block's 'Resize' command.
Returns
- Pipeline
Graphic Block SageCrmPipelineGraphicBlock object.
GetPipelineGraphicBlock(string)
Creates a Pipeline Graphic Block that has already been configured in Admin | Customization. The pipeline graphic is an implementation of the Graphic Block that includes extra functionality. You use the Pipeline Graphic to create cross-sectional diagrams that can represent data from an ASP page or data from a table. You use the parameters of this block to change the look and feel of the pipeline. You can customize individual sections of the pipeline graphic to appear differently as the user selects them (by clicking on them). Similar to the Graphics Block, the Pipeline graphic is recreated every time it is requested and can therefore be based on real time data. It can also use all of the features of the Graphics Block. The default size of the image created by the pipeline is set at 600 pixels wide and 100 in height, however it can be changed using the Graphics block's 'Resize' command.
[Obsolete("Use: new PipelineGraphicBlock(blockName)")]
public PipelineGraphicBlock GetPipelineGraphicBlock(string blockName)
Parameters
blockName
string
Returns
- Pipeline
Graphic Block SageCrmPipelineGraphicBlock object.
GetQuery()
Gets an instance of a QuerySelect that can be used to select records from the database.
Returns
- Query
Select A QuerySelect object.
GetTabs()
Adds tabs for the current context to the page.
GetTabs(string, string)
GetTabs to add the specific tab group to the page and highlight one tab
Parameters
groupName
stringName of tab group
highlight
stringTab caption (no translated), it can be find on table Custom_Tabs.Tabs_Caption.
GetTabs(string)
An overload of GetTabs to add the specific tab group to the page.
Parameters
groupName
stringName of tab group.
LogMessage(string, int)
Logs a message to the standard .NET log located in crm logs folder. Log files can be viewed in Admin/System/Logging. The message will only be logged if the level specified is greater than or equal to the current .NET logging level as set in Admin/System/Logging.
Parameters
message
stringMessage to put into file. New line and current date time will be automatically appended.
level
intThe level at which system logging must be set in order for this message to be logged.
Returns
- bool
True if successful.
LogMessage(string, string, int)
Logs a message to a new log file of your choice. The file will be created in the CRM Logs folder.
Parameters
fileName
string"System" or "SQL" for one of the existing crm log files, or any other text to create a new log file.
message
stringMessage to put into the file. Current datetime will be appended to the message automatically before writing to file.
level
intThe level at which system logging must be set in order for this message to be logged.
Returns
- bool
True if successful.
LogMessage(string)
Logs a message to the standard .NET log located in the CRM logs folder. This message will always be logged regardless of system logging level.
Parameters
message
stringMessage to put into the log file. All messages are appended onto new line and have the current date/time prepended to them.
Returns
- bool
True if successfull.
MailMerge(string, string, string, string, string, bool)
This method is obsolete on version 7.1SP2 and above Performs a mail merge of selected data from the database with a merge document in the Library of the installation.
[Obsolete("This method is obsolete on version 7.1SP2 and above")]
public string MailMerge(string sql, string nextUrl, string failUrl, string notSavedUrl, string saveDocName, bool save)
Parameters
sql
stringSQL Query to select the data.
nextUrl
stringNext URL if successful.
failUrl
stringNext URL if fails.
notSavedUrl
stringURL if not Saved.
saveDocName
stringDocument Name.
save
boolTrue to autosave the document.
Returns
- string
HTML script to be added to the content.
MailMerge(string, string, string, string, string, string, bool)
This method is obsolete on version 7.1SP2 and above. Performs a mail merge of selected data from the database with a merge document in the Library of the installation.
[Obsolete("This method is obsolete on version 7.1SP2 and above")]
public string MailMerge(string sql, string templatePath, string nextUrl, string failUrl, string notSavedUrl, string saveDocName, bool save)
Parameters
sql
stringSQL Query to select the data.
templatePath
stringPath to template document.
nextUrl
stringNext URL if successful.
failUrl
stringNext URL if fails.
notSavedUrl
stringURL if not Saved.
saveDocName
stringDocument Name.
save
boolTrue to autosave the document.
Returns
- string
HTML script to be added to the content.
MailMerge(string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string, string)
This method is obsolete on version 7.1SP2 and above Performs a mail merge of selected data from the database with a merge document in the Library of the installation.
[Obsolete("This method is obsolete on version 7.1SP2 and above")]
public string MailMerge(string database, string sql, string action, string userOptions, string save, string docLibPath, string print, string templatePath, string namedTemplate, string nextUrl, string failUrl, string notSavedUrl, string emailSubject, string saveTemplateTitle, string saveDocName, string saveDocDir, string templateName)
Parameters
database
stringDatabase Name when applicable.
sql
stringSQL Query to select the data.
action
stringMerge Action.
userOptions
stringUser options.
save
stringY or N to save or not.
docLibPath
stringprint
stringtemplatePath
stringPath to template document.
namedTemplate
stringnextUrl
stringNext URL if successful.
failUrl
stringNext URL if fails.
notSavedUrl
stringURL if not Saved.
emailSubject
stringsaveTemplateTitle
stringsaveDocName
stringsaveDocDir
stringtemplateName
string
Returns
OverrideContent(string)
This function will force CRM return ONLY the strings/values added through Web.AddContent. No HTML Tags, CSS or JavaScript will be added by CRM to the result HTML. The function AddTopContent, list pagination or any other function who need some CRM Javascript will not work properly.
Parameters
ContentType
stringContentType if null it will be set to text/html
OverrideValue(string, string)
Overrides content and query values.
Parameters
PopUpWindowButton(string, string, string, int, int)
Creates a HTML button that will open a Pop up window. Uses the UrlForPopUpWindow function to transform the passed in URL to script to open the window. Height and width parameters also need to be given. This will create the HTML that renders the image and caption.
public virtual string PopUpWindowButton(string sCaption, string sUrl, string sImage, int iHeight, int iWidth)
Parameters
sCaption
stringThe text to appear on the button.
sUrl
stringURL for the popup. This must be the complete address. You can use the 'URL' function to get this.
sImage
stringThe image name and folder. The function will apply the install name.
iHeight
intiWidth
int
Returns
PreBuildContents()
This method will be invoked before the BuildContents method and can be overriden and used to setup variables or pre-conditions for BuildContents.
RefreshMetadata(string)
Refreshes one translation family only. Run this if updating the custom_captions family directly.
Parameters
captionFamily
stringName of translation family to refresh.
RefreshMetata()
Refreshes all metadata. Run this if updating custom_* tables directly.
SetContext(string, int, bool)
SetContext for an entity with given ID.
Parameters
entityName
stringName of entity.
entityId
intID of current record.
addToRecentList
boolfalse to not add to the recent list
Remarks
A new link is added to the recent list when the SetContext is invoked and it will refer to the current DLL and Function. If Setcontext is invoked with the same value in different DLLs or functions, multiple entries will be created on the recent list, and will give the impression of duplicate links.
SetContext(string, int)
SetContext for an entity with given ID.
Parameters
SetContext(string)
Sets the context e.g. "find" or "new".
Parameters
contextString
string
Url(string)
Returns a URL for the given action that can be used on a button.
Parameters
action
stringAction number.
Returns
- string
Url string.
UrlDotNet()
Provides a URL to link directly back to the current .NET Dll.
Returns
UrlDotNet(string, string)
Provided a URL to link to another DotNetFunction within the same .NET Dll or another one.
Parameters
fileName
stringThe name of the .Net Dll.
functionName
stringThe function within the .NET Dll to call.
Returns
- string
URL string that can be used on a button or a link.
UrlForPopUpWindow(string, string, int, int)
Creates a URL that will open a pop-up window. The URL contains a field that will indicate to CRM that the page is being displayed in a Pop-up. The Popup window created with this function will have height and width set according to parameters, but scrollbars and re-size are both turned on.
Parameters
Returns
UrlForPopUpWindow(string, string, string)
Creates a URL that will open a pop-up window. Allows more properties to put on the window besides height and width.
Parameters
sUrl
stringsWindowName
stringsProperties
stringThe properties for the window e.g. "scrollbars=yes,height=700".
Returns
UrlFromKeys(string, Keys)
Gets a URL for the given action, that will include the key values.
Parameters
Returns
- string
URL string.
UrlSetKeys(string, int, int)
Creates a URL with different key values than currently used.
Parameters
AAction
stringAction number.
AJumpKey
intKey for entity to jump.
AJumpKeyValue
intKey value for jump entity.
Returns
- string
URL string.
UrlSetKeys(string, string, int)
Creates a URL for CustomEntity ASP page with different key values than currently used.
Parameters
ACustomFileName
stringThe ASP page to open.
AJumpKeyFieldName
stringAJumpKeyValue
intKeyValue for jump Entity.
Returns
- string
URL string.
Validate()
This method can be used to perform data validation on a .NET Screen after a user has submitted data.
Returns
- bool
True if successful.