setFieldValuesFromWebService

Usable on NewEdit pages and parameter pages. Executes a Web Service Call or GenAI-menu item and uses the columns returned from its @Action='Finished' call to set the values of input fields whose names match the column names. For GenAI, columns can either be returned from @Action='Finished' or @Action='StoreResponse'.

This function can only be called from a field's button javascript.

This function is unable to set the value of fields in multirows.

Example

JavaScript button

setFieldValuesFromWebService('PersonDetails_WsLookup', 'personalIdentityNumber={personalIdentityNumber}')

Web service call procedure

CREATE OR ALTER PROCEDURE dbo.PersonDetails_LookupWebServiceCall
	@Action                 varchar(100) = NULL,
	@PersonalIdentityNumber varchar(50)
AS
BEGIN
	/* ... */

	IF @Action = 'Finished'
	BEGIN
		/* Updates the fields FullName, HomeAddress and HomeZipCode with the fetched values. */
		SELECT
			D.FullName,
			D.HomeAddress,
			D.HomeZipCode
		FROM
			dbo.PersonDetails D
		WHERE
			D.PersonalIdentityNumber = @PersonalIdentityNumber;
	END;
END;

GenAI Procedure

CREATE OR ALTER PROCEDURE dbo.ChatBot_GenAI
	@Action				varchar(100) = NULL,
	@Response			nvarchar(max) = NULL,
	@TotalUsage			int = NULL
AS
BEGIN
	/* ... */

	IF @Action = 'StoreResponse'
	BEGIN
		/* Updates the fields AIResponse and AITokens with the fetched values. */
		SELECT
			@Response AS AIResponse,
			@TotalUsage AS AITokens;
	END;
END;

Usage

setFieldValuesFromWebService(menuItemAlias)
setFieldValuesFromWebService(menuItemAlias, passingfields)
setFieldValuesFromWebService(menuItemId)
setFieldValuesFromWebService(menuItemId, passingfields)

Parameters

menuItemAlias : string

Alias of menu item to call.

menuItemId : Number

Menu item to call.

passingfields : String

Values to pass to the menu item. Formatted as a standard query string.

Example: 'ssno={ssno}&task=getinfo'