NewEdit

Displays a form that is edited/inserted into the database.

Component modes: Insert record | Edit record | Duplicate record

Component mode: Duplicate record

Shows an existing record in the form and saves it as a new record.

Introduction

alt text
The NewEdit component presents a number of input fields for inserting, updating or duplicating a record in the database (see "Component mode"). There are different kinds of input fields ("Controls") for different kinds of data, such as text boxes, drop-down lists and so on. For a list of the available controls and their functionality, refer to "Controls" in the Softadmin® documentation. Here we will focus on how the controls can be presented and grouped within a NewEdit menu item.

Columns

alt text
You can split the input fields in columns. In the above example there are three columns.

alt text
If the browser window is too narrow, the input fields will not rearrange. Instead you will get a horizontal scrollbar.

Buttons

alt text
The default buttons are "Save" and "Cancel", but you can change their wording, or specify a completely different set of buttons.

Confirm close

alt text
To prevent losing data, the NewEdit component will raise a warning if you try to leave the page without saving changes. It does not appear if you have not made any change to any of the input fields. The warning also appears if you close the browser window.

JavaScript button

alt text
Every control can display one or more buttons to their right. In this example, the dropdown list with available customers is accompanied by a "New customer" button.

alt text
It opens a menu item to create a new customer, displayed in a popup window.

alt text
In this example, the user created a new customer named Carl Carlsson. When the new customer is saved, it is automatically added to the customer dropdown in the "Edit car" menu item. Notice that the user did not have to reenter all the other data, like Model, Year model, Price etc, since the New customer menu item took place in a popup window.

Controls

These are the controls available in the NewEdit component:

Component settings

Cancel button text
Sets the label of the cancel button. Use either a custom text or a language phrase id.
Confirm close
Whether a warning should be shown when the user tries to leave the page while there are unsaved changes. The default value is taken from the NewEditConfirmClose application variable.
Id parameter name
The name of the id parameter sent to the GetEditFields and Update procedures. Defaults to "Id".
Id to edit
The value of the id parameter supplied to the GetEditFields and Update procedures.
Submit button text
Sets the label of the submit button. Use either a custom text or a language phrase id.

SQL

SQL Call: Retrieve record (mandatory)

Retrieves the record to edit in the form.

May modify database: No

Parameters

@<Id parameter name> string
The id-value of the record being edited.

Resultset: Specify number of columns (optional)

Specifies the number of columns to display forthcoming fields and how to allocate those fields to columns.
Table count: repeated zero or more times
Row count: exactly one row
Columns
AdminColumns mandatory int
The number of columns to display forthcoming result sets.
AdminLayout optional string
Specifies how the fields are allocated into columns.
Default: If omitted the 'column' layout type is assumed.
Possible value Description
column The component expects n resultsets to follow and allocates the fields in the same resultset to a separate column.
row The component expects one resultset to follow where the n first fields are allocated to row one, the next n fields to row 2, etc... Fields on the same row will be aligned (middle) with each other.

Resultset: Fields to edit

Return the fields to edit as columns.
Table count: repeated one or more times
Row count: exactly one row
Columns
<fieldname> optional string
Field to display in form. If there exists a querystring parameter with the same name as the field, then the field will be automatically hidden and have its value set to the querystring parameters value.

Resultset: Dynamic field information (optional)

Specify extra field information for the fields on the page.
Table count: repeated zero or more times
Row count: zero or more rows
Columns
AdminFieldName mandatory string
The name of the field to apply the information to. The presence of this column indicates that the resultset specifies field information.
AllowHtml optional bit
Allow HTML.
ButtonJavaScript<xxx> optional string
Inserts a button next to the control that is used to execute the JavaScript supplied here. <xxx> is an arbitrary text that can be empty if only one button is required.
ButtonJavaScript<xxx>_Label optional string
The label for the JavaScript button <xxx>.
CellAlignment optional string

The alignment of grid columns and InfoSQL values.

Possible value Description
center Only applicable to grid columns.
left
right
ColumnTooltip optional string
Sets the tooltip on the column title. Only supported by the Grid component.
DefaultValue optional string
The default value for the control or if prefixed by 'SQL:' the sql to run to determine the default value.
DefaultValueSql optional string
SQL that evaluates default value for field. Can contain other fields for value dependency.
Description optional string
The description for the field.
EnabledJavaScript optional string
Javascript that controls the enabled status of the field. The control is only enabled if the expression specified here evaluates to true. The expression is evaluated every time the value of a dependent control is changed. This is only available to control types for which the enabled javascript field is visible in the user interface.
FieldGroupId optional int
The field group to use.
FieldInfoId optional int
ID of field information to base the dynamic field on. All properties not explicitly overridden by dynamic field information will be copied from this field. The referenced field must be found in the menu item's field tables.
FieldLabel optional string
If present the field label is used as the heading for fields instead of the field name.
FieldType optional string
The name of the control type to use. It is usually recommended to use FieldInfoId instead unless the column is used to make fields hidden or uneditable.
Possible value Description
boolean checkbox Legacy alias. Use "checkbox" instead.
boolean dropdown
chart
checkbox
checkbox tree
colorpicker
date
datetime
dropdown
file
file upload area
heading
heading with checkbox
hidden
html
info text
listbox
multi-autosearch
multi-listbox
multi-picker
multirow
password
picture
radio buttons
radio cards
signature
textarea
textbox
textbox with autosearch
textbox with autosuggest
textbox with dropdown
textbox with popup
time
uneditable text
Height optional int
The height of the control.
IgnoreOnSave optional bit
Do not pass the field value to the insert/update procedure.
InfoSqlLayout optional string
Where the label is shown in relation to the contents in InfoSQL.
Possible value Description
Default Inherit layout from menu item.
LabelAbove Full width, label above.
LabelLeft Label to the left.
NoLabel Full width, no label.
Standard Deprecated. Use LabelLeft instead.
MandatoryJavaScript optional string

JavaScript that controls the mandatory status of the field, this overwrites nullchoice if set. This is only available to control types for which the mandatory JavaScript field is visible in the user interface.

MaxDate optional date
Only applicable to the Date and Datetime controls.
MinDate optional date
Only applicable to the Date and Datetime controls.
NullChoice optional bit
Specifies whether the control allows null values.
NumberOfDecimals optional int
The number of decimals to display for numeric values.
OnChangeJavaScript optional string
Javascript run when the value of the control has changed.
OutputFormat optional string
Special formatting to be applied when the field is displayed.
Possible value Description
Hyperlink
MailToLink
PhoneLink
Placeholder optional string
Text shown when the field is empty.
Sql optional string
The SQL that determines the control's behavior. (Refer to control documentation for more information)
TextDirection optional string

Which direction the script is written in. Not to be confused with the CellAlignment property.

Possible value Description
default System default. Not useful unless you are trying to override an already explicit text direction on existing field information.
ltr Left-to-right (for example English)
rtl Right-to-left (for example Arabic)
ThousandDelimiter optional string
The thousand grouping delimiter for numeric values.
TimePickerFrom optional string
Only applicable to the Time and Datetime controls.
TimePickerTo optional string
Only applicable to the Time and Datetime controls.
Width optional int

The width of the control.

At one point, this was a pixel value. Back when Softadmin used Verdana 10px, and before fields had width-categories. Now, it is just a value that is converted to a width category.

The possible values listed below are just suggestions. For example, both 1 and 30 will be converted to shortest, and both 500 and 9999 to longest.

Possible value Description
150 Medium-long
30 Shortest
300 Long
500 Longest
60 Short
90 Medium short
VisibleJavaScript optional string
JavaScript that controls the visibility of the field. The control is only visible if the expression specified here evaluates to true. The expression is evaluated every time the value of a dependent control is changed.

Resultset: Button specification (optional)

Overrides the standard Save and Cancel buttons.
Table count: repeated zero or one time
Row count: one or more rows
Columns
AdminButtonId mandatory string

The specified AdminButtonId is passed to the insert/update procedure in the @AdminButtonId parameter when the button is clicked.

If this column is null the button will act as the default save button, i.e. the @AdminButtonId parameter will not be supplied and the button will be triggered by the Ctrl+S and Enter keyboard shortcuts.

ButtonText optional string
The text of the button.
Default: If both PhraseId and ButtonText are null the default save button phrase will be used, unless CidStepsBack is non null. If CidStepsBack is non-null the default Cancel button phrase will be used.
CidStepsBack optional int

If specified, the button acts as a cancel button, i.e. the InsertUpdate procedure will not be called and the cancel action will be triggered. The button also responds to the Esc keyboard shortcut.

Default: If omitted the button will not be a cancel button.
EnforceMandatoryFields optional bit
Whether mandatory fields should be forced to contain a value.
Default: Validates mandatory fields unless CidStepsBack has a value.
PhraseId optional string
Phrase id for the text of the button.
Default: If both PhraseId and ButtonText are null the default save button phrase will be used, unless CidStepsBack is non null. If CidStepsBack is non-null the default Cancel button phrase will be used.

Resultset: JavaScript lookup functions (optional)

If you have fixed lookup tables that fields need for visibility scripts then you can have NewEdit generate JavaScript lookup functions.

For example

SELECT
	ComponentId AS ADMINJavaScriptLookup,
	HasComponentSql AS componentHasSql,
	HasInfoSql AS componentHasInfoSql
FROM dbo.ADMINComponent
Table count: repeated zero or more times
Row count: zero or more rows
Columns
ADMINJavaScriptLookup mandatory int
This must be the first column in the table.
xxx mandatory int

For each column xxx a JavaScript function xxx is generated. The function maps the id values in the ADMINJavaScriptLookup-column to the values in the xxx-column.

If this is a bit column then the SQL value 1 is converted to the JavaScript value true, and both 0 and NULL are converted to false.

SQL Call: Validate parameters

Allows you to validate the SQL parameters before any other SQL is run in the component. This call is only made if the SQL is a stored procedure and Validate parameters is checked.

May modify database: No

Parameters

@Force bit
Set to 1 if the last call to validate parameters used admin_force and the user clicked OK in the OK/Cancel dialog.
@ValidateParams bit
Set to 1 when this call is made.

Resultset: Messages (optional)

Table count: repeated zero or one time
Row count: zero or one row
Columns
ADMIN_Force optional string
Message asking the end user to confirm their parameters.
ADMIN_Message optional string
Message explaining why the parameters are rejected.

Insert/Update/Delete SP

SQL Call: Insert record (mandatory)

Inserts a new record into the database.

NOTE: Fields that both have validation and are hidden (e.g. with Visibility JavaScript) are passed as NULL to the procedure.

May use SoftadminApi.Progress_SetTitle and SoftadminApi.Progress_SetStep.

Supports custom errors: Yes
May modify database: Yes

Resultset: Clear cache and forwarding definitions (optional)

Specify which menuitem to forward to and clear any cached data that has been invalidated.
Table count: repeated zero or more times
Row count:
Columns
ADMIN_ErrorMessage optional string

Displays a user friendly error message to the user. This blocks any forwarding for the user.

ADMIN_ConfirmDelete optional string

Displays a user friendly confirmation message to the user with a delete button as the confirm button. If the user chooses OK the SQL call will be rerun with the parameter @ButtonAction set to 'Delete'.

ADMIN_ConfirmQuestion optional string

Displays a user friendly confirmation message to the user with a question style. If the user chooses OK the SQL call will be rerun with the parameter @ButtonAction set to 'Confirm'.

ADMIN_ConfirmWarning optional string

Displays a user friendly confirmation message to the user with a warning style. If the user chooses OK the SQL call will be rerun with the parameter @ButtonAction set to 'Confirm'.

ADMIN_InfoMessage optional string

Displays a user friendly info message to the user. When the user clicks OK the user is forwarded.

ADMIN_SuccessMessage optional string

Displays a user friendly success message to the user. When the user clicks OK the user is forwarded.

ADMIN_Dialog optional string

The dialog alias of a predefined dialog to show the user. Must be the first column in the result set table. Use multiple result set tables to combine with other forwarding.

Use the menu item "Admin > Dialogs" to register new dialogs or find aliases for existing ones.

<xxx> (for ADMIN_Dialog) optional any

Any column without special meaning in the result set with the first column ADMIN_Dialog will be used to make replacements of placeholders in the message and title text.

ADMIN_DebugInfo optional string

Additional information to show the developer when using ADMIN_Dialog.

<passing_field> optional string
Any column with no other specific meaning will pe passed along to the menu item you are forwarding to.
ADMIN_CancelCidStepsBack optional int
Number of steps in the page history to jump back if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelcidstepsback specified in the query string.
ADMIN_CancelReturnToMenuItem optional string
Jumps back to the menu item with this alias if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). If no prior menu item is found with the given alias, then an error is thrown.
ADMIN_CancelMenuItem optional string
Alias of the menu item to execute if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelmenuitemid specified in the query string.
ADMIN_CancelMenuItemId optional int

Deprecated. Use ADMIN_CancelMenuItem instead.

Id of the menuitem to execute if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelmenuitemid specified in the query string.

ADMIN_CidStepsBack optional int
Number of steps in the page history to jump back after execution (the default being one step back). This value overrides any destination specified by the query string.
ADMIN_ReturnToMenuItem optional string
Jumps back to the menu item with this alias after execution. This value overrides any destination specified by the query string. If no prior menu item is found with the given alias, then an error is thrown.
ADMIN_Force optional string
Prompts the user with the specified text and the user may answer OK or cancel. If the user chooses OK the sql call will be rerun with the parameter @force set to 1.
ADMIN_Forward optional string
Displays a user friendly message and then forwards to the next menu item.
ADMIN_ForwardLink optional string
Alias of the link to forward to.
ADMIN_ForwardMenuGroup optional string

Alias of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.

ADMIN_ForwardMenuGroupId optional int

Deprecated. Use ADMIN_ForwardMenuGroup instead.

Id of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.

ADMIN_ForwardMenuItem optional string
Alias of the menu item to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.
ADMIN_ForwardMenuItemId optional int

Deprecated. Use ADMIN_ForwardMenuItem instead.

Id of the menu item to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.

ADMIN_Message optional string

Displays a user friendly error message to the user.

ADMIN_PasteHtmlFromPopup optional string
Pastes HTML into an HTML editor. See ADMIN_SetFieldValueFromPopup.
ADMIN_SetFieldValueFromPopup optional string
Sets the value of the field specified in the menuitempopup call. Only select this column if menu item is opened in a popup.
ADMIN_ClosePopup optional bit
If this column is anything but NULL the popup will be closed. Only select this column if the menu item is opened in a popup.
Default: The default behavior is to step back inside the popup window and close it if there is nothing to step back to.
ADMIN_ClosePopupAndReloadOpener optional bit

If this column is anything but NULL the popup will be closed and the parent will be reloaded. Only select this column if the menu item is opened in a popup. Avoid using this feature if the opener is a newEdit as that may interrupt the user's ongoing input.

ADMIN_Unselect optional bit
Alias for ADMIN_UnselectAll.
ADMIN_UnselectAll optional bit
If this column is anything but NULL all items are removed from the list of selected items.
Default: By default selected items are maintained when you return to the grid/calendar. This applies even if the selected item is no longer visible in the component unless this column is specified.
ADMIN_ClearHistory optional any
When the value is not NULL all navigation history is cleared and the user can't navigate back. This is only supported when forwarding to another menu item.
ADMIN_RefreshMenu optional bit
Will trigger a reload of the sidebar if the column is anything but NULL.
Cache optional string
Cache key to be cleared. Supports wildcards.
CacheUserId optional string
Either a user id or '%'.

Clears all caches (e.g. access permissions) related to the specified user id.

Use '%' to clear caches for all users.
CancelButtonText optional string

Changes the text of the Cancel button when used with ADMIN_Force, ADMIN_ConfirmWarning, ADMIN_ConfirmQuestion, ADMIN_ConfirmDelete.

OkButtonText optional string

Changes the text of the OK button when used with ADMIN_ErrorMessage, ADMIN_ConfirmWarning, ADMIN_ConfirmQuestion, ADMIN_ConfirmDelete, ADMIN_InfoMessage, ADMIN_SuccessMessage, ADMIN_Message, ADMIN_Force, or ADMIN_Forward. ADMIN_Force,

Resultset: Raise sync entity (optional)

This SQL call may use SoftadminApi.SyncEntity_RaiseChanged.

Table count: repeated zero or more times
Row count:
Columns

InfoSQL

See the InfoSQL documentation for details.

Custom access control and logging

SQL Call: Custom access control and logging

Use this call to restrict which entries a user is allowed to view and edit, and to log which entries a user views.

Access to a menu item is normally controlled through functions and roles alone but some entities need more fine grained control. For example, a user may have access to the View Member menu item for normal members but not for members with a protected identity.

The menu items a user visits are always logged (in ADMINLogMenuItem) but for sensitive data you may need to log exactly what entries are viewed. Do the logging in this call as the common ways of viewing data (grid and InfoSQL) are not allowed to modify the database.

If you bind a scalar function instead of a stored procedure to this call then its name must end with '_GrantAccess'.

May modify database: Yes

Resultset: Access permissions

Return whether the user is allowed to visit the menu item with the current parameters.
Table count: repeated exactly once
Row count: exactly one row
Columns
GrantAccess mandatory bit
1 if the user is allowed to view the menu item, 0 if the user should not be allowed to view the menu item.

If 0 then an error will be logged as the user should not have been able to reach the menu item with the given parameters in the first place.

Querystring parameters

menuitemheading optional
String that replaces the menu item name when the menu item is loaded. It does not replace the name before that (like for example in the navigator). It is ignored if the menu item is displayed as a part in a multipart in which case the name can be set from the multipart procedure.

Examples

How to handle transactions

Avoid using nested transactions (since only the outermost matters regarding ROLLBACK or COMMIT). The following code only starts transactions when necessary, ie if one has not already been started. Make sure to look at the @IsUsingLocalTransaction parameter before any COMMITs or ROLLBACKs.

-----------------------
-- Begin transaction --
-----------------------

DECLARE
	@IsUsingLocalTransaction	bit

IF @@TRANCOUNT = 0
BEGIN
	SET XACT_ABORT ON
	BEGIN TRANSACTION

	SELECT
		@IsUsingLocalTransaction = 1
END

--------------------------
-- INSERT/UPDATE/DELETE --
--------------------------

<DML statements>

------------------------
-- Commit transaction --
------------------------

IF @IsUsingLocalTransaction = 1
BEGIN
	COMMIT TRANSACTION
END

Dynamic field info - NewEdit

Example of how dynamic field info can be used to change the properties of fields in a NewEdit.

ALTER PROCEDURE Example.NewEdit_DynamicFieldInfoGetEditFields
AS
BEGIN

	-----------------------
	-- Fields to NewEdit --
	-----------------------

	SELECT
		-- In this example, this field keeps its original field info
		CONVERT(varchar(1000), NULL) AS [ExampleFieldChangedByDynamicFieldInfo1],
		-- And these fields will have their field changed by dynamic field info
		CONVERT(varchar(1000), NULL) AS [ExampleFieldChangedByDynamicFieldInfo2],
		CONVERT(varchar(1000), NULL) AS [ExampleFieldChangedByDynamicFieldInfo3],
		CONVERT(varchar(1000), NULL) AS [ExampleFieldChangedByDynamicFieldInfo4]

	------------------------
	-- Dynamic field info --
	------------------------

	/*
		You don't have to SELECT all dynamic field info in one result set,
		the presence of the column [ADMINFieldName] in the result sets tells
		Softadmin® that the result set specifies dynamic field info.

		The basic structure is to specify the field to change in a column [ADMINFieldName],
		the other columns are the properties to be changed. NULL values are
		interpreted as keeping the static field info.
	*/
	
	SELECT
		-- Field to change
		'ExampleFieldChangedByDynamicFieldInfo2' AS [ADMINFieldName],
		-- Properties to change
		'Look how I''ve changed the label but not the description' AS [FieldLabel],
		NULL AS [Description]	-- NULL value, original description will be used

	SELECT
		-- Field to change
		 'ExampleFieldChangedByDynamicFieldInfo3' AS [ADMINFieldName],
		-- Properties to change
		 'Look how I''ve changed the description, width and height' AS [Description],
		 400 AS [Width],
		 225 AS [Height]

	SELECT
		-- Field to change
		 'ExampleFieldChangedByDynamicFieldInfo4' AS [ADMINFieldName],
		-- Properties to change
		 'Look how I''ve changed the label, type and default value' AS [FieldLabel],
		 'Uneditable text' AS [FieldType],
		 '* Try and change me if you can *' AS [DefaultValue]

END

Column layout

There are many different ways of dividing fields into columns using ADMIN_Columns. The red arrows indicate tab-order.

alt text

ALTER PROCEDURE Example.ColumnLayout_GetEditFields
	@id int = NULL
AS
BEGIN
	/* ONE COLUMN, ONE HEADER */
	SELECT
		1 AS ADMINColumns;

	SELECT
		NULL AS HeadingA1,
		NULL AS FieldA1,
		NULL AS FieldA2,
		NULL AS FieldA3,
		NULL AS FieldA4
	WHERE
		1 = 0;

	/* TWO INDEPENDENT COLUMNS, ONE HEADER */
	SELECT
		1 AS ADMINColumns;

	SELECT -- The heading must be in its own table to span both columns.
		NULL AS HeadingB1
	WHERE
		1 = 0;

	SELECT
		2 AS ADMINColumns;

	SELECT
		NULL AS FieldB1,
		NULL AS FieldB2
	WHERE
		1 = 0;

	SELECT
		NULL AS FieldB3,
		NULL AS FieldB4
	WHERE
		1 = 0;

	/* TWO DEPENDENT COLUMNS, ONE HEADER */
	SELECT
		1 AS ADMINColumns;

	SELECT -- The heading must be in its own table to span both columns.
		NULL AS HeadingC1
	WHERE
		1 = 0;

	SELECT
		2 AS ADMINColumns,
		'ROW' AS ADMINLayout;

	SELECT
		NULL AS FieldC1,
		NULL AS FieldC2,
		NULL AS FieldC3,
		NULL AS FieldC4
	WHERE
		1 = 0;

	/* TWO COLUMNS, TWO HEADERS */
	SELECT
		2 AS ADMINColumns;

	SELECT
		NULL AS HeadingD1,
		NULL AS FieldD1,
		NULL AS FieldD2
	WHERE
		1 = 0;

	SELECT
		NULL AS HeadingD2,
		NULL AS FieldD3,
		NULL AS FieldD4
	WHERE
		1 = 0;


	/* Dynamic field info */
	SELECT
		'HeadingA1' AS ADMINFieldName,
		'One column, one header' AS FieldLabel,
		'Heading' AS FieldType;

	SELECT
		'HeadingB1' AS ADMINFieldName,
		'Two independent columns, one header' AS FieldLabel,
		'Heading' AS FieldType;

	SELECT
		'HeadingC1' AS ADMINFieldName,
		'Two dependent columns, one header' AS FieldLabel,
		'Heading' AS FieldType;

	SELECT
		'HeadingD1' AS ADMINFieldName,
		'Two columns, left header' AS FieldLabel,
		'Heading' AS FieldType;

	SELECT
		'HeadingD2' AS ADMINFieldName,
		'Two columns, right header' AS FieldLabel,
		'Heading' AS FieldType;

	SELECT
		CONCAT('Field', L.Letter, N.Num) AS ADMINFieldName,
		CONCAT('Field ', L.Letter, N.Num) AS FieldLabel
	FROM (VALUES (1), (2), (3), (4)) AS N(Num)
	CROSS JOIN (VALUES ('A'), ('B'), ('C'), ('D')) AS L (Letter);
END;

Using progress output

This code demonstrates how to use the process functions to maintain a progress bar during processing.

CREATE TABLE #ToPostProcess
(
	ThingyId int not null
);

 /* Choose things to post-process here */
INSERT #ToPostProcess (ThingyId)
SELECT n
FROM SoftadminUtil.Number_Range(1,5);

EXEC SoftadminApi.Progress_SetTitle
	@TitleText = 'Post processing thingies';

DECLARE
	@CompletedSteps int = 0,
	@TotalSteps int = (SELECT COUNT(*) FROM #ToPostProcess);

DECLARE ThingyCursor CURSOR LOCAL FOR
SELECT
	ThingyId
FROM
	#ToPostProcess;

OPEN ThingyCursor;
WHILE 1=1
BEGIN
	EXEC SoftadminApi.Progress_SetStep
		@CompletedSteps = @CompletedSteps,
		@TotalSteps     = @TotalSteps;

	DECLARE @ThingyId int;
	FETCH ThingyCursor INTO @ThingyId;

	IF @@FETCH_STATUS <> 0
		BREAK;

	/* Post-process Thingy with id @ThingyId here */
	-- EXEC Example.Thingy_PostProcess @ThingyId = @ThingyId;

	SET @CompletedSteps += 1;
END
CLOSE ThingyCursor;
DEALLOCATE ThingyCursor;

DROP TABLE #ToPostProcess;

Best practice

Name of stored procedures

The edit fields stored procedure should be named "<Schema>.<Table>_GetEditFields". The insert/update procedureshould be named "<Schema>.<Table>_InsertUpdate" (or just "Insert" or "Update" if the procedure doesn't handle both actions).