Altiris Software Dev Kit (ASDK)

 View Only

 Creating Jobs and Tasks via ASDK

Jump to Best Answer
Rufus Swart's profile image
Rufus Swart posted Nov 12, 2020 07:03 AM
Hi,

I'm looking to be able to create a job and task with conditions using the ASDK on ITMS 8.5 RU 3, the creation of the Job and tasks are all fine but when I try to create a condition I'm unable to do so.

Reviewing the XML and the condition xml seems different and was wondering if there is additional xml needed?

Here is the steps I'm following:

1.) create task -> save return GUID of task
2.) create client job -> save return GUID of client job
3.) add task to client job -> save return task node GUID
4.) create condition -> error 

The asdk example is:

Guid jobGuid = new Guid("Some GUID");
Guid taskGuid = new Guid("Some task GUID");

// add existing task to a Job
var taskNodeGuid = m_proxy.AddTaskFirstToJob(jobGuid, taskGuid);

// define conditions to be evaluated
string conditionRules = @"
<conditionRules>
    <rule>
        <taskNodeGuid>"+ taskNodeGuid + @"</taskNodeGuid>
        <conditionType>WHERE</conditionType>
        <conditionOperator>Equals</conditionOperator>
        <conditionValue>4</conditionValue>
    </rule>
    <rule>
        <taskNodeGuid>"+ taskNodeGuid + @"</taskNodeGuid>
        <conditionType>OR</conditionType>
        <conditionOperator>Equals</conditionOperator>
        <conditionValue>5</conditionValue>
    </rule>
</conditionRules>";

// create condition
var conditionNodeGuid = m_proxy.CreateJobCondition(jobGuid, taskNodeGuid, conditionRules);

// NB! save it only if finally completed editing a Job
m_proxy.ConfirmJobChanges(jobGuid);
​
The error in the Altiris log viewer is:

Failed parse job condition rules

Invalid parameter xml. A task output property name field was not supplied
   [Altiris.ASDK.ASDKInvalidParameterException @ Altiris.ASDK.Task]
   at Altiris.ASDK.Task.Utilities.BuildJobConditionRuleCollection(String xml)
   at Altiris.ASDK.Task.Web.TaskManagementService.CreateJobCondition(Guid jobGuid, Guid taskNodeGuid, String conditionRules)

Exception logged from: 
   at Altiris.ASDK.Task.Web.TaskManagementService.CreateJobCondition(System.Guid, System.Guid, String)
   at RuntimeMethodHandle.InvokeMethod(Object, Object[], Signature, Boolean)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object, Object[], Object[])
   at System.Reflection.RuntimeMethodInfo.Invoke(Object, System.Reflection.BindingFlags, System.Reflection.Binder, Object[], System.Globalization.CultureInfo)
   at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object, Object[])
   at System.Web.Services.Protocols.WebServiceHandler.Invoke()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
   at System.Web.Services.Protocols.SyncSessionlessHandler.ProcessRequest(System.Web.HttpContext)
   at System.Web.Script.Services.ScriptHandlerFactory+HandlerWrapper.ProcessRequest(System.Web.HttpContext)
   at System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStepImpl(System.Web.HttpApplication+IExecutionStep)
   at System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication+IExecutionStep, Boolean&)
   at System.Web.HttpApplication+PipelineStepManager.ResumeSteps(Exception)
   at System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext, AsyncCallback)
   at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest, System.Web.HttpContext)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)
   at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus&)
   at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr, System.Web.RequestNotificationStatus&)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr, IntPtr, IntPtr, Int32)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr, IntPtr, IntPtr, Int32)

User [DOMAIN\MYUSER], Auth [Soap_Proxy], AppDomain [/LM/W3SVC/1/ROOT/Altiris/ASDK.Task-8-132496556473666125]

HTTP [POST]: https://XXX/Altiris/ASDK.Task/TaskManagementService.asmx
 ip: [192.168.10.12]; content-length: [720];
 response: [200 OK]; x-smp-nsversion: [8.5.5032.0];

-----------------------------------------------------------------------------------------------------
Date: 11/12/2020 1:54:10 PM, Tick Count: 105787859 (1.05:23:07.8590000), Host Name: XXX, Size: 3.01 KB
Process: w3wp (25924), Thread ID: 166, Module: w3wp.exe
Priority: 1, Source: Altiris.ASDK.Task.Web.TaskManagementService.CreateJobCondition
File: C:\ProgramData\Symantec\SMP\Logs\a.log
​

If anyone know where to obtain the new way of adding job conditions please let me know.

Thanks in advance .

Rufus Swart
Denis Utrobin's profile image
Broadcom Employee Denis Utrobin Best Answer

Hi Rufus,

The parameter "taskOutputPropertyName" is missing in condition rules of the example - the name of the output parameter which is being part of a sub-task's or sub-job's result, which value to be evaluated in condition. The name of base output parameters: "@ReturnValue", "@Success", "@LogOutput". Please note, that the output parameter "@LogOutput" is used only by task.  If you want to work with the Script Task result, you may use its output parameter "ScriptOutput" or "ScriptErrorOutput".

The same issue for the next methods: "CreateJobCondition", "AddJobConditionRules", "AddTaskToJobConditionThenGroup", AddTaskToJobConditionElseGroup". 

The valid example:

Guid jobGuid = new Guid("Some GUID");
Guid taskGuid = new Guid("Some task GUID");

// add existing task to a Job
var taskNodeGuid = m_proxy.AddTaskFirstToJob(jobGuid, taskGuid);

// define conditions to be evaluated
string conditionRules = @"
<conditionRules>
    <rule>
        <taskNodeGuid>"+ taskNodeGuid + @"</taskNodeGuid>
        <taskOutputPropertyName>@ReturnValue</taskOutputPropertyName>
        <conditionType>WHERE</conditionType>
        <conditionOperator>Equals</conditionOperator>
        <conditionValue>4</conditionValue>
    </rule>
    <rule>
        <taskNodeGuid>"+ taskNodeGuid + @"</taskNodeGuid>
        <taskOutputPropertyName>@ReturnValue</taskOutputPropertyName>
        <conditionType>OR</conditionType>
        <conditionOperator>Equals</conditionOperator>
        <conditionValue>5</conditionValue>
    </rule>
</conditionRules>";

// create condition
var conditionNodeGuid = m_proxy.CreateJobCondition(jobGuid, taskNodeGuid, conditionRules);

// NB! save it only if finally completed editing a Job
m_proxy.ConfirmJobChanges(jobGuid);



Alex Hedley's profile image
Alex Hedley
If you manually create a job with conditions and export the item and look into the XML are they any extra nodes included in the <conditionRules>.

I've not checked over the docs but there is no mention of needing a "name" field?
Invalid parameter xml. A task output property name field was not supplied
One other thing to check is the examples folder with the ASDK help, is there sample for conditions in there?
Rufus Swart's profile image
Rufus Swart
HI Alex,

I have checked, there is no example in the ASDK samples folder for the job condition, there is only the example within the help ASDK8.5.chm file.

If I manually create the job and add the condition, the xml does not reference any <conditionRules> anywhere. I believe the xml is parsed and then the internal method creates the required.

If I inspect the manually created job there is a reference to a Property Name:
I have logged a support case to ask for the documentation to be updated, but the standard support response to ASDK is not supported and send the link to the asdk documents. If someone from PM team can confirm the steps for a basic example or give insight into the <conditionRules> xml that might be a help but no luck with support as yet.
Rufus Swart's profile image
Rufus Swart
the screenshot isn't clear:

<inputMap>
<input nodeGuid="4f641359-a85c-4133-a9a8-b382621c870d">
<params/>
</input>
<input nodeGuid="ad5f34f8-9de6-425b-b51d-062c5d6c63a2">
<params>
<param name="4f641359-a85c-4133-a9a8-b382621c870d_@ReturnValue" type="Altiris.TaskManagement.Common.PreviousTaskOutputParameterValue, Altiris.TaskManagement.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=99b1e4cc0d03f223">
<PreviousTaskOutputParameterValue xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<JobNodeGuid>
<Guid>4f641359-a85c-4133-a9a8-b382621c870d</Guid>
</JobNodeGuid>
<PropertyName>@ReturnValue</PropertyName>
</PreviousTaskOutputParameterValue>
</param>
</params>
</input>
</inputMap>​
Alex Hedley's profile image
Alex Hedley
The ASDK is absolutely supported, I'm not sure who gave you that response but I'd challenge that, it's part of the solution.
Alex Hedley's profile image
Alex Hedley
Can you try it directly on the server calling the WebService through IE and just paste in the same inputs, see if that gets the same error?
Rufus Swart's profile image
Rufus Swart
The Test form is only available for methods with primitive types so I can’t test it there.
Rufus Swart's profile image
Rufus Swart
Hi Denis,

Thanks for the explanation, my issue was resolved. How can I request that the ASDK documentation be updated?

Every time I log a support case I have endless issues explaining to the support engineers that the issue is related to the ASDK and not to the custom development, the simply ignore this and close the calls with a link to the documentation, which in this case was not up to date.

Kind Regards,
Rufus
Vladimir Zelenjak's profile image
Broadcom Employee Vladimir Zelenjak
Hi Rufus,

We'll make sure we do update the documentation in the next release.

Answering your question on ASDK issues and support - I recommend you report on the Community portal here.
EPM Engineering team is reviewing posts and trying to assist.

Thanks,
Vlad.
Kimer Lime's profile image
Kimer Lime
Awesome tips! top-notch develops, we engaged mlsdev for custom software development and were very pleased with their depth of knowledge, creativity, and professionalism. The product was delivered as described and on time. will definitely do business with you again, highly recommend it.
Rufus Swart's profile image
Rufus Swart

Hi Denis Utrobin,

I'm updating my app to work with 8.7, and encounter this error again, this time slightly different, now following the same steps I can't get it to work with 8.7 testing using Postman. previously the Altiris log viewer would log the error but now in 8.7 there is nothing, the retun on postman is http 400 bad request (The request cannot be fulfilled due to bad syntax) now there is no way to know where the bad syntax is since the ASDK documentation was not updated: Symantec ASDK API documentation

Broadcom remove preview
Symantec ASDK API documentation
The Symantec Administrator Software Development Kit (ASDK) provides an application programming interface (API) that you can use to automate and customize the Sy
View this on Broadcom >

Thanks,

Rufus