Custom Function

On this page you can create or update a Custom Function.

The Source Code can be C# or SQL and in either case valid Custom Function Code should be entered.

Checking Source Code for errors

You can validate the Source Code by clicking the button labelled 'Validate'. This will check that Medidata Rave considers the Source Code to be valid. Where possible the line(s) which have error(s) will be indicated with an error icon in the left-hand side bar.

Note

TrialGrid will use a recent version of Medidata Rave to validate the Source Code. It is possible that older versions of Medidata Rave validate Source Code differently (for example, having fewer restrictions on allowed C# methods). For this reason TrialGrid will allow Source Code with errors to be saved.

Editor buttons

The source code editor has the following buttons to help with editing:

  • Search:

    After clicking the Search button, enter a string in the search box and type Enter. The editor will highlight all instances of that string in the Source Code. The search is case sensitive. Case insensitive (and other more complicated searches) can be done using regular expressions, e.g. /ae/i will perform a case insensitive search for the text 'ae', matching 'ae', 'AE', 'Ae', 'aE'.

  • Find Previous

    Move to the previous result of searching (if any)

  • Find Next

    Move to the next result of searching (if any)

  • Replace

    After clicking the Replace button, enter a string in the Replace box and type Enter. The editor will highlight all instances of that string in the Source Code. You can choose to Replace one-by-one, all or none. The search is case sensitive. Case insensitive (and other more complicated searches) can be done using regular expressions, e.g. /ae/i will perform a case insensitive search for the text 'ae', matching 'ae', 'AE', 'Ae', 'aE'.

  • Undo

    This will undo the most recent, unsaved, change (if any).

  • Redo

    This will undo the most recently undone edit (if any).

  • Remove whitespace and comments

    Clicking this button will progressively remove more whitespace and comments to reduce the number of characters in the Source Code, which might be useful if approaching the 8000 character Medidata Rave limit.

    Each time the button is clicked it will:

    • remove empty double-spaced lines

      If the source code now has fewer characters it will stop, otherwise it will continue:

    • remove spaces from the beginning of lines

      If the source code now has fewer characters it will stop, otherwise it will continue:

    • remove single-line comments

      If the source code now has fewer characters it will stop, otherwise it will continue:

    • remove multi-line comments

      If the source code now has fewer characters it will stop, otherwise it will continue:

    • remove all new lines

      No further changes will be made.

    Warning

    Changes made to remove whitespace and comments can be undone before the Custom Function is saved but after it has been saved there is no undo or revert option. Use this button with caution!

  • Dedent

    The start of the current source code line will be moved to the left.

  • Indent

    The start of the current source code line will be moved to the right.

  • Auto-indent

    All source code will be automatically indented.

Keyboard shortcuts

The source code editor has keyboard shortcuts to assist with search and replace. The keyboard shortcuts are active when the cursor is inside the source code text area.

  • Ctrl-F / Cmd-F

    Start searching

  • Ctrl-G / Cmd-G

    Find next

  • Shift-Ctrl-G / Shift-Cmd-G

    Find previous

  • Shift-Ctrl-F / Cmd-Option-F

    Replace

  • Shift-Ctrl-R / Shift-Cmd-Option-F

    Replace all

    (Use the tab key to move between the Yes/No/All/Stop options)

  • Alt-G

    Jump to line

Autocomplete

While editing C# Source Code you can display an autocomplete list using Control-Space (press and hold the Control key and then the Space key). This will display a list of allowed C# classes and methods taken from the Medidata Rave documentation

The autocomplete list will be filtered using the text to the left of the cursor. For example showing autocomplete for this C# code

DataPoint.Enter

will display an autocomplete list starting with:

DataPoint.Enter(string, string, int)
DataPoint.Enter(string, string, Medidata.Core.Objects.DataEntryState)
DataPoint.Enter(string, string, string, int)

You can use the scroll up and down the list using the mouse or keyboard. Typing more characters will filter the list further. You can select an item using the mouse or with the Tab key.

The method signatures are displayed in the autocomplete list but will not be inserted into the code on selection of an item.

Note

Classes and methods which are deprecated by Medidata and/or not supported in Medidata Rave EDC (RaveX) are highlighted in red.

Note

The autocomplete functionality is not 'intellisense'. It filters the list based on the text to the left of the cursor but does not analyze the code to work out class types. In the following code no autocomplete will be displayed because TrialGrid does not know that 'dp' is a DataPoint

DataPoint dp = afp.ActionDataPoint;
dp.Enter

Custom Function Length

The number of characters in the Custom Function Source Code will be displayed at the bottom right. Medidata Rave accepts a maximum of 8000 characters. Note that each line break counts as 2 characters in Medidata Rave.

Note

A warning symbol will be displayed next to the number of characters if the number of characters is less than, but close to the 8000 character limit. Sometimes Medidata Rave will not import Custom Functions which are close to 8000 characters in length.