• Jason_Terlizzi
  • NEWBIE
  • 5 Points
  • Member since 2018
  • Sr. Solutions Architect
  • Levementum

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Hi All, 
 

I have a Script Activity running in an automation in a parent BU. The Script activity calls an automation in a child BU and 'should' start that automation. Everything is running fine in the parent automation, meaning the automation script activity runs. I navigate to the child BU and see the automation that should have been called to run wasn't. 

Has anyone ran into this issue? Below is my sample code: 

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

Platform.Load("Core","1.1.1");

var automationCustomerKey = "B2BDEUPDATE";

var rr = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.SetObjectProperty(rr, "ObjectType", "Automation");
Platform.Function.AddObjectArrayItem(rr, "Properties", "ProgramID");
Platform.Function.AddObjectArrayItem(rr, "Properties", "CustomerKey");
Platform.Function.AddObjectArrayItem(rr, "Properties", "Status");

var sfp = Platform.Function.CreateObject("SimpleFilterPart");
Platform.Function.SetObjectProperty(sfp, "Property", "CustomerKey");
Platform.Function.SetObjectProperty(sfp, "SimpleOperator", "equals");
Platform.Function.AddObjectArrayItem(sfp, "Value", automationCustomerKey);

Platform.Function.SetObjectProperty(rr, "Filter", sfp);

var retrieveStatus = [0,0,0];

var automationResultSet = Platform.Function.InvokeRetrieve(rr, retrieveStatus);

var ObjectID = automationResultSet[0]["ObjectID"];
var Status = automationResultSet[0]["Status"];

if (ObjectID != "null") {

    /*
    Code Status
    -1   Error
     0   BuildingError
     1   Building
     2   Ready
     3   Running
     4   Paused
     5   Stopped
     6   Scheduled
     7   Awaiting Trigger
     8   InactiveTrigger
    */

    if (Status == 2) {

       //  var obj = Platform.Function.CreateObject("Automation");
       // Platform.Function.SetObjectProperty(obj, "ObjectID", ObjectID);
       // var po = Platform.Function.CreateObject("PerformOptions");

       // var performResult = [0,0,0];
       // var performStatus = Platform.Function.InvokePerform(obj, "start", performResult, po);

    } else {
      // already running

    }
} else {
   // automation not found
}

var username = '[User]';
var password = '[PW]';
var payload = '';
var endpoint = "https://webservice.s10.exacttarget.com/Service.asmx";
//Automation Customer Key
var customerKey = '[Automation Key]';
var result;
//Create a DE for logging if logging is needed.
//var logDE = DataExtension.Init("Triggered_Automation_Log");

startAutomation();

function startAutomation() {
        payload += '<?xml version="1.0" encoding="utf-8"?>';
        payload += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
        payload += '   <soapenv:Header>';
        payload += '      <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">';
        payload += '         <wsse:UsernameToken wsu:Id="UsernameToken-32259181" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">';
        payload += '            <wsse:Username>' + username + '</wsse:Username>';
        payload += '            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">' + password + '</wsse:Password>';
        payload += '         </wsse:UsernameToken>';
        payload += '      </wsse:Security>';
        payload += '   </soapenv:Header>';
        payload += '   <soapenv:Body>';
        payload += '        <PerformRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">';
        payload += '            <Action>start</Action>';
        payload += '            <Definitions>';
        payload += '                    <Definition xsi:type="Automation">';
        payload += '                    <Client>';
        payload += '                        <ID>100013681</ID>';
        payload += '                    </Client>';
        payload += '                             <CustomerKey>' + customerKey + '</CustomerKey>';
        payload += '                    </Definition>';
        payload += '            </Definitions>';
        payload += '        </PerformRequestMsg>';
        payload += '   </soapenv:Body>';
        payload += '</soapenv:Envelope>';

        try {
                result = HTTP.Post(endpoint,"text/xml",payload,['SOAPAction'],['Perform']);
        } catch(e) {
                // logDE.Rows.Add({Status:500,Message:Stringify(e)});
        }

        if (result.StatusCode != 200) {
            //Bad response
            // logDE.Rows.Add({Status:result.StatusCode,Message:Stringify(result)});
        } else {
            //Good response
                var status = Stringify(result.Response[0]).match(/<OverallStatus>([^<]*)<\/OverallStatus>/)[1];
                var requestId = Stringify(result.Response[0]).match(/<RequestID>([^<]*)<\/RequestID>/)[1];

                // logDE.Rows.Add({Status:status,RequestId:requestId});
        }
}
</script>
 

I am getting the error message "Challenge Not yet complete... here's what's wrong: 
'Accounts Temp Access' doesn't exists as a type flow. Check the instructions"
But the flow very much exists.  Any ideas?
Permission flow error screen shot