cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

How to pass parameters to purgeSelectedPropertyHistory correctly?

bmitioglov
7-Bedrock

How to pass parameters to purgeSelectedPropertyHistory correctly?

Hi,


I am trying to purge value streams for two properties. But getting the Null pointer exception after executing the following code:


var params = {

propertyNames: { "items": ["propA", "propB"] }

};

// result: INFOTABLE dataShape: "undefined"

var namedProperties = me.GetNamedProperties(params);

var paramsForPurge = {

propertiesToPurge: namedProperties /* INFOTABLE */,

endDate: Date.now(),

startDate: new Date(new Date().setFullYear(new Date().getFullYear() - 1))

}

me.PurgeSelectedPropertyHistory(paramsForPurge);

What I am doing wrong?

2 REPLIES 2
jdass
13-Aquamarine
(To:bmitioglov)

Hi Boris,

Please check if the GetNamedProperties service returns the correct property names (without the values).

Or try using the PurgePropertyHistory service to purge the properties one by one and let me know if you are still getting the Null Pointer .


var params = {
propertyName: "propA" /* STRING */,
immediate: true /* BOOLEAN */,
    endDate: Date.now(),
    startDate: new Date(new Date().setFullYear(new Date().getFullYear() - 1))
};

me.PurgePropertyHistory(params);


var params = {
propertyName: "propB" /* STRING */,
immediate: true /* BOOLEAN */,
    endDate: Date.now(),
    startDate: new Date(new Date().setFullYear(new Date().getFullYear() - 1))
};

me.PurgePropertyHistory(params);

I see this question wasn't answered... Today I've needed the service and autodiscovered the correct way on specifying the property names.

You should pass a DataShape on which Property Name field it's propertyName not name. Something like:

var propertiesToPurge = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape( {

                        infoTableName : "InfoTable",

                        dataShapeName : "CustomDataShapeWithAFieldAsPropertyName"

                    });

propertiesToPurge.AddRow({ propertyName: "propA" });

propertiesToPurge.AddRow({ propertyName: "propB" });

me.PurgeSelectedPropertyHistory({

     propertiesToPurge: propertiesToPurge,

     startDate: 0,

     endDate: dateAddYears((new Date()),1000)

});

Announcements


Top Tags