This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Update AlertStatus record

I would like to update the an AlertStatus record programatically.

I am able to update the TriggerCount and the Notes field as well.  I would like to do an update of the LastUpdate record.

I am doing this is perl.

This is working:

       my $result = $swql->swis->Update($alert->{uri}, {

                                                    'TriggerCount'=> $alert->{triggercount} + 1,

                                                    'Notes' => $notes,

                                                   });

This is NOT working:

     my $time = '2014-04-17T17:31:18';

       my $result = $swql->swis->Update($alert->{uri}, {

                                                    'TriggerCount'=> $alert->{triggercount} + 1,

                                                     'LastUpdate'=> "CAST('".$time."' AS DATETIME)",

                                                    'Notes' => $notes,

                                                   });

Keep getting this error:

ERROR SolarWinds.InformationService.Core.InformationService - Exception caught in method Update

System.InvalidOperationException: Unable to cast from String to DateTime

   at SolarWinds.Data.Query.Expressions.ScalarExpression`1..ctor(T scalar, TypeInformation type)

   at SolarWinds.Data.Query.Expressions.QueryExpressionFactory.MakeScalarExpression[T](T value, TypeInformation type)

   at SolarWinds.InformationService.Core.CrudProcessor.MakeScalarExpression(Object value, TypeInformation typeInfo)

   at SolarWinds.InformationService.Core.CrudProcessor.MapPropertiesToColumns(IDictionary`2 properties, IMappingFragment fragment, IQueryExecutionContext context)

   at SolarWinds.InformationService.Core.CrudProcessor.UpdateInternal(Boolean bulkMode, SwisUriResolver uriResolver, IDictionary`2 propertiesToUpdate, IQueryExecutionContext context)

   at SolarWinds.InformationService.Core.CrudProcessor.Update(IServiceHost serviceHost, SwisUri uri, IDictionary`2 propertiesToUpdate, IQueryExecutionContext context)

   at SolarWinds.InformationService.Core.InformationService.Update(String uri, IDictionary`2 propertiesToUpdate)

',

    'faultMessage' => 'Unable to cast from String to DateTime',

    'faultstring' => 'Update failed, check fault information.'

Any assistance will be appreciated.

Charles

  • It looks like you are putting a SQL expression as a string into the LastUpdate property. That won't work - it needs to be a string that is convertible to a datetime. Try this:

    my $time = '2014-04-17T17:31:18';

           my $result = $swql->swis->Update($alert->{uri}, {

                                                        'TriggerCount'=> $alert->{triggercount} + 1,

                                                         'LastUpdate'=> $time,

                                                        'Notes' => $notes,

                                                       });