0

The status for this InvokePerform is coming back as undefined. Any ideas what is wrong with my code?

<script language="javascript" runat="server">

    Platform.Load("core", "1");
    var QD_ExternalKey = "d9868a1f-875d-4723-b0bb-14b5b514a671";

    var APIObject = Platform.Function.CreateObject("QueryDefinition");
    Platform.Function.SetObjectProperty(APIObject, "CustomerKey", QD_ExternalKey);

    var newObject = Platform.Function.InvokePerform(APIObject, "Start", StatusAndRequestID, Options);
    var statusMessage = StatusAndRequestID[0];
    var errorCode = StatusAndRequestID[1];
    var performResponse = StatusAndRequestID[2];

</script>

statusMessage: <ctrl:var name=statusMessage />
errorCode: <ctrl:var name=errorCode />
performResponse: <ctrl:var name=performResponse />

Output:
statusMessage: undefined

errorCode: undefined

performResponse: undefined

1

In order to perform, InvokePerform an QueryDefinition object, it requires passing in the ObjectID instead of the CustomerKey. If you need to get the ObjectID then InvokeRetrieve can be used.

<script language="javascript" runat="server">
    Platform.Load("core", "1");

    var APIObject = Platform.Function.CreateObject("QueryDefinition");     
        Platform.Function.SetObjectProperty(APIObject, "ObjectID", "Your ObjectID here");   
    var StatusAndRequestID = [0,0,0];
    var newObject = Platform.Function.InvokePerform(APIObject, "Start", StatusAndRequestID,Options);

    var statusMessage = StatusAndRequestID[0];
    var errorCode = StatusAndRequestID[1];
    var performResponse = StatusAndRequestID[2];

</script>

statusMessage: <ctrl:var name=statusMessage /> 
errorCode: <ctrl:var name=errorCode /> 
performResponse: <ctrl:var name=performResponse />

Output: statusMessage: QueryDefinition perform called successfully
errorCode: 0
performResponse: {JSON Response}

Related Post: Manage automation via ampscript API

  • Great, thank you! I had to use an InvokeRetrieve() to obtain the ObjectID value for my query definition. – Daniel Jul 13 '16 at 4:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.