Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

Wednesday, 28 August 2013

External Assemblies - Referencing, Packaging and Applying Across Instances

To reference an external .net assembly in an application object:

  • First add the DLL to the \inetpub\webui\bin folder.
  • Go to the Code page of the app. object and select the References tab. 
  • Click the Add button next to References and in the popup window, scroll the tabs right and select the .net Assemblies tab.
  • Select the name of the assembly, click the Select button then click OK.
When packaging an extracted object from another instance that references an external assembly, first copy the external assembly to the \utilities\utilities3e folder. Otherwise critical errors will be reported in the Utilities3e Package step and the operation will fail.

Thursday, 8 March 2012

Current Instance URL

To return the URL of the currently running instance, from a code page use:

Me.ConfigMgr.GetApplicationURLBase()

Returning, for example: http://server01/instance01/webui

Friday, 3 February 2012

Exception Raising

The standard method of raising exceptions in 3e is to display them in the top Exception panel - the panel shared with other item lists such as the Worklist.
Exception raised in Proforma Generation Process
To raise an exception in this way, the Exception property of the Process's underlying Object must be set to an instance of the NxApplicationException class. For example, from within the Object:
Me.Exception = New NxApplicationException(New Guid("430e4f35-2834-46ea-b031-b718054c7f62"))

Or from a Process:
Me.ProfMaster.ProformaCollection(0).Exception = New NxApplicationException(New Guid("430e4f35-2834-46ea-b031-b718054c7f62"))

The GUID value is set to the Id of a Message that describes the error.
To remove the Exception, set the Exception property to null:
Me.Exception = Nothing

Thursday, 8 December 2011

Right-Click Cancel on Processes

Right-clicking on a Process in My Action List shows a handy Cancel pop up menu. Using this short cut can be much quicker than opening the Process and then cancelling from within a new page.
Cancel a Process from the Action List

For a right-click cancel to work, the Process must contain a path that leads to an end point without intervening steps.

Right-click cancel possible - A Process with a route to an end point with no steps (the bottom "Cancel" route)

Right-click cancel not possible - A process without a "no-step" route to a end point 

When a Process does not contain a route without intermediate steps, an error is show when attempting to cancel from the Action List.

Error message from a failed right-click Process cancel
However, intermediate steps are sometimes required when cancelling a Processes to perform certain tasks or return to a previous state. Unlocking records or freeing up resources for example. Rather than adding a step and preventing a right-click Action List cancel, the code that would be in the step can be written in the Else rule before the end point.

The Else rule (selected in blue) before the end step

This way, clean-up functionality can still run when the user cancels from the Action List.

Tuesday, 6 December 2011

Process Else Rules - Accessing the DataObject in Code

Within the Code tab of a Process, the Base Object can be accessed as a property. For example, the evaluation of CUSTOM rules can sometimes require a decision to be made based on a value contained within the Base Object.
Access to the ProfMaster Base Object from a custom rule in Process code
Function Evaluate As System.Boolean
Return Me.IM_AutoBillEdit.IsOutsideProcess.Value(False)
End Function

However, this Base Object property is not accessible in Else rules. To access it, cast Me.Process to its type and then access individual objects though the object collection.
Access to the ProfMaster Base Object from an ELSE rule in Process code
Public Overrides Sub OnRule()
For Each profMasterItem As ProfMaster In _
CType(Me.Process, NextGen.Application.Process.ProfProcess). _
ProfMasterCollection

NextMessage = profMasterItem.Description
Next
End Sub

Wednesday, 5 October 2011

Spell Check

Spell check can be called natively on a Narrative type Attribute. In the Object, call Me.<AttributeName>.SpellCheck(), a pop-up window appears if any spelling mistakes are found.

Spell check can also be called on a Card Object by casting to an ICard type and calling RunSpellCheck().

Monday, 19 September 2011

Launching Dashboards or Report Layouts with Parameters

Method: Pass the parameters in the URL.

Step 1: Parameter Object
The parameter object attached to the Dashboard or Report Layout must be able to interpret the URL. This can be done in the AfterAdd handler method.

Example:

Protected Overrides Sub AfterAdd()
Dim strMatterIndex As System.String

' call stock object after add code
MyBase.AfterAdd()

' get matter number from url
strMatterIndex = System.Web.HttpContext.Current.Request.Item("MatterIndex")

' if there is a matter index
If Not String.IsNullOrEmpty(strMatterIndex)

' set matter index parameter
Me.Matter.Value = CInt(strMatterIndex)

' auto submit parameters
CType(Me, IParamObject).IsAutoSubmitParamObject = True
Else
' don't auto submit parameters
CType(Me, IParamObject).IsAutoSubmitParamObject = False
End If
End Sub


Step 2: Launching Object
Create a URL Action on the launching Object and implement the Execute function.
Return the URL for the Dashboard or Report Layout with the required parameters appended.

Example:

Protected Overrides Function Execute() As System.String
If Me.Owner.Matter.IsNull Then
Return Nothing
Else
Return String.Format("{0}&SID={1}&MatterIndex={2}", _
Me.UrlMgr.GetDashboardUrl("IM_ENQUIRY_MATTER"), _
Me.UserMgr.SessionID, Me.Owner.Matter.Value)
End If
End Function


Step 3: Action
Add the URL Action to a UI element.

Friday, 16 September 2011

Circular Dependency

Circular dependency in objects is not checked for on the save or build of individual files.

However, errors can arise when trying to:

  • Using 'Build Project' from the context menu of a project in IDE.
  • Using 'Update 3E - Extract' in the Upgrades section of Utilities 3E.

If both of these processes fail, chances are that a circular dependency exists in at least one of the project's objects.

To find the culprit, build each object individually with a Build Type of 'All AppObjects that use <Obj_Name> (Runtime Only)'. A circular dependency exception will show in the build output of the problem object.

Friday, 2 September 2011

DataObject Construction

To instantiate a new DataObject use the following:

Dim newTestObject As New TestObject(Me.ProcessAppMgr, CType(NextGen.Framework.Managers.AssemblyMgr.NxAssemblyMgr.GetObjectSchema("TestObject"), Schema.ISchema))

This is the way to create new data objects on the fly without having to load them from archetypes.

Thursday, 19 May 2011

No Intellisense in IDE

No Intellisense showing in the IDE code page? CTRL + SPACE not showing the helpful drop down?

Sometimes this just happens, especially when the code contains errors. Usually, a CodeDOM rebuild (CTRL + SHIFT + B), then a code parse (CTRL + R) will solve the issue.

However, this doesn't always work - even though you are well within your rights to be shown some Intellisense. In that case, try closing and reopening the object. If that gives on joy, try restarting the IDE.

After that, you're on your own.

Monday, 18 April 2011

Add Saved Objects to Collections

To display a previously saved object in an object collection, use Me.Populate(<obj_id(s)>) from within the object's Collection Code.

Tuesday, 5 April 2011

Code vs Collection Code

Applies to Objects and ReportObjects:
  • Code interacts with each item (object) in the current dataset. Methods such as BeforeUpdate() and AfterPopulate() will run for each item. The collection that contains the object is accessed via Me.ParentCollection. Use this option for changing the behaviour of on-form controls, such as Attribute read only access and value validation.
  • Collection Code runs against the whole dataset. Methods such as BeforeUpdate() and AfterPopulate() will run only once. Individual items in the collection can be access via Me.ActiveItems. Use this option when making comparisons over the whole dataset or when running finalising code after all data has been updated.
Events trigger at the item level before they trigger at the collection item. For example when saving to the database, AfterSave()will be called on the item, then on the item's collection.