Skip to Main Content
Return to Navigation

PTDiagnostics Class Methods

This section discusses the diagnostic methods for the PTDiagnostics PeopleCode class. The methods are listed in alphabetical order.

GetDiagnosticInfo

Description

Use this required public method to define the code that retrieves diagnostic information and returns it to Diagnostics Framework for presentation to the user. This method is invoked by Diagnostics Framework to initiate information collection, then output the results.

The GetDiagnosticInfo method uses the base class InsertData method to pass the results of the diagnostic to Diagnostics Framework for presentation to the users, for example:

&status = %Super.InsertData("Number", "Number of Records: ", &rs1.RowCount);

InsertData can pass output data using the following data types:

  • String

  • Number

  • Date

  • Boolean

  • Rowset

Before you can pass rowset data as output, you must first use the base class SetProperty method to set the base class hasRowset property to True.

Considerations for GetDiagnosticInfo include:

  • You can pass only one data type in each diagnostic plug-in application class. To return multiple data types, define multiple application classes. Results that are passed to the framework are retained in memory.

  • If you're also defining the GetDynamicPrompt method to prompt users for additional information, use the base class GetUserInputByKey method to retrieve the user responses, for example:

    &status = %Super.GetUserInputByKey("Recs", &sVal);
    
  • For more readable output, use the base class SetProperty method to insert a description into the base class Purpose property, for example:

    &status = %Super.SetProperty(%This, "Purpose", "String", "This is a diagnostic to
     determine your license code.");

Note: You can also set the Purpose property in the constructor or in the GetDynamicPrompt method.

Example

Following is an example of GetDiagnosticInfo that passes rowset data as output:

method GetDiagnosticInfo
   Local boolean &status;
   Local number &rc1;
   Local Rowset &rs1;
   Local string &sError;
   
   &rs1 = CreateRowset(Record.PSLANGUAGES);
   &rc1 = &rs1.Fill();
   &status = %Super.SetProperty(%This, "hasRowset", "Boolean", True);
   &status = %Super.InsertData("Rowset", "LANGUAGES description, not used in
 output", &rs1);
   
end-method;

GetDynamicPrompt

Description

If you want a diagnostic application class to prompt users for additional information that you can use as dynamic criteria for the diagnostic, you must define a public method called GetDynamicPrompt within the class.

Before you can use the GetDynamicPrompt method, you must first use the base class SetProperty method within the constructor to set the base class Where property to True , for example:

&status = %Super.SetProperty(%This, "Where", "Boolean", True);

Note: If the Where property is False, Diagnostics Framework ignores the GetDynamicPrompt method.

Within the GetDynamicPrompt method, use the base class InsertQuestion method to define the questions used to prompt the users.

Example

method GetDynamicPrompt
   Local boolean &status;
   
   &status = %Super.InsertQuestion("Recs", "Enter Records to search for, beginning
 with: ", "String", True);
end-method;

GetUserInputByKey

Syntax

GetUserInputByKey(sKeyID, &data)

Description

The GetUserInputByKey method retrieves the user response to a question, which can then be used as an input parameter in the diagnostic. You invoke this method within the GetDiagnosticInfo method.

Parameters

Parameter

Description

sKeyID

Specify as a string the key that identifies the question for which you're retrieving the user response.

&data

Provide a variable to contain the retrieved user response.

Returns

A Boolean value: True if the user response was retrieved successfully, False otherwise.

InsertData

Syntax

InsertData(propFormat, propDescr, &data)

Description

The InsertData method passes data to Diagnostics Framework to be presented as the output of the diagnostic. This enables you to pass any information you want without having to hardcode base class methods in the plug-in. You invoke this method within the GetDiagnosticInfo method.

Parameters

Parameter

Description

propFormat

Specify as a string the data type of the data to be presented. Select from the following:

  • String

  • Number

  • Date

  • Boolean

  • Rowset

propDescr

Specify a string of text to describe or introduce the output data.

&data

Provide the output data value, in a variable of the data type specified by the propFormat parameter.

Returns

A Boolean value: True if the data has been inserted into Diagnostics Framework, False if the data can't be inserted into the framework, or if the data type specified by propFormat doesn't exist in the current framework.

InsertQuestion

Syntax

InsertQuestion(sKeyID, sQuestion, sType,  GblBool)

Description

The InsertQuestion method passes a question to Diagnostics Framework, which then presents it to the user to obtain an input parameter. You invoke this method within the GetDynamicPrompt method.

Parameters

Parameter

Description

sKeyID

Specify as a string a key to identify the question. This value must be unique across all plug-ins that are made available to a user.

sQuestion

Specify as a string the question you want the user to answer.

sType

Specify as a string the data type of the response required from the user. Select from the following:

  • String

  • Number

  • Date

  • Boolean

GblBool

Specify a Boolean value indicating the scope of the question:

  • True: The question applies globally to the plug-in.

  • False: The question applies only to the current class.

Global questions are asked once per plug-in on the Additional Information prompt page. For example, a plug-in could be defined to gather employee information. The plug-in might contain many application classes that gather specific information (for example, one application class for getting employee paycheck information, and one application class for getting employee addresses). Class level questions are asked only for the current application class. For example, for the paycheck information, you might want to prompt for specific pay periods and for the address information, you might want to prompt for an effective date.

Returns

A Boolean value: True if the method is successful, False otherwise.

IsPlugIn

Description

This required public method is invoked by Diagnostics Framework when you register the plug-in. It verifies that the class is part of a diagnostic plug-in. If it is not present, the system will not register the plug-in.

IsPlugIn should be:

  • at the end of the Diagnostic Application Class.

  • an empty method.

Example

method IsPlugIn
end-method

SetProperty

Syntax

SetProperty(&obj, propName, propFormat,  &propValue)

Description

The SetProperty method sets a property of an instantiated PTDiagnostics object to the value that you specify.

Parameters

Parameter

Description

&obj

Specify the PTDiagnostics object for which you want to set a property. Typically, you'll specify %This.

propName

Specify as a string the name of the property that you want to set. The values are:

  • hasRowset

  • Purpose

  • Where

propFormat

Specify as a string the data type of the property that you want to set. For hasRowset and Where, specify Boolean. For Purpose, specify string.

&propValue

Provide the property value, in a variable that has the data type specified by the propFormat parameter.

Returns

A Boolean value: True if the property specified by propName exists and can be set in the base class, False if the property can't be set (for example, if the current plug-in is used in a previous release of Diagnostics Framework where that property isn't defined).