Account data
Updated at:
Copy as MD
When account authentication is enabled for a web visualization application, account data such as phone numbers, email addresses, and account names become available. You can set request parameters when configuring data analysis services, custom interfaces, or business service APIs to store and pass this account data to implement custom UI or features. For example, when calling an API in the web application, you can select account data as a dynamic request parameter to display content specific to the logged-in account.
Prerequisites
You have completed the following tasks:Procedure
- On the App Development page, in the Development Tools section, click Business Logic.
- On the business logic workbench, create a service API with request parameters. This example shows how to configure a simple HTTP request that returns static data.
- Create a business service. For instructions, see Create a business service.
- On the business logic editing page, click the node button on the left. From the Input tab, drag an HTTP request node onto the canvas and configure it as follows.
In the Action field, enter
GetData. Click + Add Input Parameter. In the Add Parameter dialog box, set the parameter name tonumand the type to Int. Select Required, set the default value to0, and click OK. - From the Function tab, drag a Condition node onto the canvas and configure it as shown.
On the configuration panel on the right, click the + Condition button. In the condition configuration dialog box, set Data Source to From Node and select the num field from the HTTP request node. Set the comparison method to ==. For the second data source, select Fixed Value, set the data type to Number, enter
10111as the value, and then click OK. - From the Output tab, drag two HTTP response nodes onto the canvas and configure them as follows.
Configure the nodes to return the string "test" if the condition is met, and the number 100 otherwise. In the Output area of the HTTP response node configuration panel, select the Fixed Value option.
- In the upper-right corner of the page, click Save, Deploy, Debug, and then Publish sequentially to publish the service.
- Open the editor for the web visualization application that you created. Drag a text component onto the canvas. In the style panel on the right, click the Configure Data Source button next to Text.
- In the data source configuration panel, select the service API that you created in Step 3, and then select Dynamic Parameter.
Select the checkbox for the parameter num, and then click Parameter Source.
- Click Parameter Source and select Logged-in Account.
- In the Logged-in Account dialog box, configure the data and click OK.
Parameter Description Return Type The type of value returned for the current account. Options include phone number, email address, and account name. In this example, Account Name is selected. The service API returns a result based on whether the account name meets the configured condition.
Debug Value Optional. During application development, no logged-in account information is available. If you need to preview the API response, you can set a debug value that corresponds to the Return Type. In this example, the value is set to 10111.
You can view the API response under Response in the data source configuration panel. In this example, Dynamic Parameter is selected, the parameter name isnum, Auto Update is checked, the value is taken from the logged-in accountname[10111], which produces the response"test". - Click OK to finish configuring the data source.
Next steps
After you finish configuring the web visualization application, publish it.Note When you log on to the published application, the API that is configured with Logged-in Account as the parameter source will return and display data based on your account information.
Is this page helpful?