Select to view content in your preferred language

Arcade Console Function Output Destination

514
1
Jump to solution
02-07-2023 07:24 AM
Paul_K
by
New Contributor II

The Arcade Console app would be helpful for debugging Arcade scripts if I can access the Arcade Console function output in a WPF application that is using styles. Does the output go to the application standard output stream? Or, is there an API to access Arcade's Console output stream? How is the Arcade Console function output accessed in a WPF application?

0 Kudos
1 Solution

Accepted Solutions
JenniferNeryEsri
New Contributor II

You can use  ArcGISRuntimeEnvironment.ArcadeConsoleMessage event and write to file or standard console.

For example, if adding a new feature triggers an attribute rule that contains Console function in the ScriptExpression, we would expect this event to be raised with the message from Console function and some information about the rule and table.

 

ArcGISRuntimeEnvironment.ArcadeConsoleMessage += (sender, eventArgs) =>
{
    // eventArgs.Context.Profile (i.e. ArcadeProfile.AttributeRuleCalculation)
    // eventArgs.Context.Information (i.e. ruleName, tableName for attribute rules)
    // eventArgs.Message (i.e. Console(<message>))
};

var sgdb = await ServiceGeodatabase.CreateAsync(new Uri(featureServerUrl));
var table = sgdb.GetTable(1);
await table.LoadAsync();
 
var feature = table.CreateFeature();
await table.AddFeatureAsync(feature); // triggers attribute rule with Console(<message>)

 

View solution in original post

1 Reply
JenniferNeryEsri
New Contributor II

You can use  ArcGISRuntimeEnvironment.ArcadeConsoleMessage event and write to file or standard console.

For example, if adding a new feature triggers an attribute rule that contains Console function in the ScriptExpression, we would expect this event to be raised with the message from Console function and some information about the rule and table.

 

ArcGISRuntimeEnvironment.ArcadeConsoleMessage += (sender, eventArgs) =>
{
    // eventArgs.Context.Profile (i.e. ArcadeProfile.AttributeRuleCalculation)
    // eventArgs.Context.Information (i.e. ruleName, tableName for attribute rules)
    // eventArgs.Message (i.e. Console(<message>))
};

var sgdb = await ServiceGeodatabase.CreateAsync(new Uri(featureServerUrl));
var table = sgdb.GetTable(1);
await table.LoadAsync();
 
var feature = table.CreateFeature();
await table.AddFeatureAsync(feature); // triggers attribute rule with Console(<message>)