0

I configured two custom send classifications in marketing cloud. I need to retrieve send classification's Descriptions and Names from Data Views. I retrieved only SendClassification's external keys (e.g. 1234) configuring this data view _Job. Could you tell me if there is a way to manage it?

1 Answer 1

2

It's not possible to get send classification metadata from Data Views, so you would need to retrieve this information from the SOAP API and place the data in a Data Extension to use in your Query Activities.

Data Extension

Create a Data Extension called "SendClassifications" in your Business Unit with these fields:

enter image description here

SSJS Script Activity

Create an SSJS Script Activity in Automation Studio with the following code:

<script runat="server">
    Platform.Load("Core","1");

    // Data Extension to upsert to
    var deKey = "SendClassifications";

    // Create an API Retrieve Request
    var RetrieveRequest = Platform.Function.CreateObject("RetrieveRequest");

    // Set the request type
    Platform.Function.SetObjectProperty(RetrieveRequest, "ObjectType", "SendClassification");

    // Set the columns
    Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "ObjectID");
    Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "Name");
    Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "SendClassificationType");
    Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "Description");
    Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "CreatedDate");
    Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "ModifiedDate");
    Platform.Function.AddObjectArrayItem(RetrieveRequest, "Properties", "CustomerKey");

    // Do the retrieve
    var StatusAndRequestID = [0,0];
    var SendClasses = Platform.Function.InvokeRetrieve(RetrieveRequest, StatusAndRequestID);

    // Loop though Send Classifications and upsert DE
    for ( var sc = 0 ; sc < SendClasses.length ; sc ++ )
    {
        // Define the key with which to update/insert
        var filterNames = ["ObjectID"];
        var filterValues = [SendClasses[sc].ObjectID];

        // Data Extension fields to upsert to
        var updateNames = ["Name","SendClassificationType","Description","CreatedDate","ModifiedDate","CustomerKey"];

        // Define the values to update
        var updateValues =  [
                            SendClasses[sc].Name,
                            SendClasses[sc].SendClassificationType,
                            SendClasses[sc].Description,
                            SendClasses[sc].CreatedDate,
                            SendClasses[sc].ModifiedDate,
                            SendClasses[sc].CustomerKey
                        ];

        try{
            var rows = Platform.Function.UpsertData(deKey,filterNames,filterValues,updateNames,updateValues);
            Write("Rows Upserted in SendClassifications: " + rows + "<br />");
        } catch (err){
            throw new UserException("Error upserting Send Classification rows.");
        }
    }
</script>

Query Activity

Create your Query Activity that now includes your SendClassifications table. Something like this...

SELECT
    j.JobID,
    j.EmailName,
    sc.Description
from
    _job j WITH (NOLOCK) INNER JOIN
    SendClassifications sc
        ON  j.SendClassification = sc.CustomerKey

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .