{"id":31374,"date":"2018-04-21T15:47:45","date_gmt":"2018-04-21T15:47:45","guid":{"rendered":"https:\/\/ampscript.guide\/functions-createobject\/"},"modified":"2021-04-06T01:18:20","modified_gmt":"2021-04-06T01:18:20","slug":"createobject","status":"publish","type":"post","link":"https:\/\/ampscript.guide\/createobject\/","title":{"rendered":"CreateObject"},"content":{"rendered":"<h2>CreateObject<\/h2>\n<p>This function instantiates the specified <a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.mc-apis.meta\/mc-apis\/supported_operations_for_objects_and_methods.htm\">Marketing Cloud API Object<\/a>.<\/p>\n<blockquote>\n<p>NOTE: Instantiated objects do not persist after the first subsequent Invoke function call (for example, <code>InvokeRetrieve()<\/code>, <code>InvokeUpdate()<\/code>, etc.).<\/p>\n<\/blockquote>\n<h3>Argument<\/h3>\n<p><code>CreateObject(1)<\/code><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center\">Ordinal<\/th>\n<th style=\"text-align: left\">Type<\/th>\n<th style=\"text-align: left\">Required<\/th>\n<th style=\"text-align: left\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center\">1<\/td>\n<td style=\"text-align: left\">String<\/td>\n<td style=\"text-align: left\">True<\/td>\n<td style=\"text-align: left\">The name of the API Object to instantiate<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Example<\/h3>\n<p>The following example retrieves all of the <code>DataExtenion<\/code> objects in a specific DataFolder (<code>CategoryID<\/code>).  The <code>CreateObject()<\/code> line specifies the object to instantiate.<\/p>\n<pre><code>%%[\n\nvar @rr, @CategoryID, @Name, @CustomerKey\nset @rr = CreateObject(\"RetrieveRequest\")\nSetObjectProperty(@rr, \"ObjectType\", \"DataExtension\")\nAddObjectArrayItem(@rr, \"Properties\", \"CategoryID\")\nAddObjectArrayItem(@rr, \"Properties\", \"Name\")\nAddObjectArrayItem(@rr, \"Properties\", \"CustomerKey\")\n\nset @sfp = CreateObject(\"SimpleFilterPart\")\nSetObjectProperty(@sfp, \"Property\", \"CategoryID\")\nSetObjectProperty(@sfp, \"SimpleOperator\", \"equals\")\nAddObjectArrayItem(@sfp, \"Value\", \"13755\")\n\nSetObjectProperty(@rr,\"Filter\", @sfp)\n\nset @rows = InvokeRetrieve(@rr, @rrStatus, @rrRequestID)\n\noutput(concat(\"rrStatus: \", @rrStatus))\noutput(concat(\"&lt;br&gt;rrRequestID: \", @rrRequestID))\n\nfor @i = 1 to RowCount(@rows) do\n\n  set @row = Row(@rows, @i)\n  set @CategoryID = Field(@row, \"CategoryID\")\n  set @Name = Field(@row,\"Name\")\n  set @CustomerKey = Field(@row, \"CustomerKey\")\n\n  output(concat(\"&lt;br&gt;CategoryID: \", @CategoryID, \", Name: \", @Name, \", CustomerKey: \", @CustomerKey))\n\nnext @i\n\n]%%<\/code><\/pre>\n<h4>Output<\/h4>\n<pre><code>rrStatus: OK\nrrRequestID: 677010b6-69d4-4839-bf59-b342d3440ca5\nCategoryID: 13755, Name: LoyaltyMembers, CustomerKey: LoyaltyMembers\nCategoryID: 13755, Name: CouponCodes, CustomerKey: CouponCodes<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CreateObject This function instantiates the specified Marketing Cloud API Object. NOTE: Instantiated objects do not persist after the first subsequent Invoke function call (for example, InvokeRetrieve(), InvokeUpdate(), etc.). Argument CreateObject(1) Ordinal Type Required Description 1 String True The name of the API Object to instantiate Example The following example retrieves all of the DataExtenion objects [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v14.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The AMPscript Guide - CreateObject<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ampscript.guide\/createobject\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The AMPscript Guide - CreateObject\" \/>\n<meta property=\"og:description\" content=\"CreateObject This function instantiates the specified Marketing Cloud API Object. NOTE: Instantiated objects do not persist after the first subsequent Invoke function call (for example, InvokeRetrieve(), InvokeUpdate(), etc.). Argument CreateObject(1) Ordinal Type Required Description 1 String True The name of the API Object to instantiate Example The following example retrieves all of the DataExtenion objects [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ampscript.guide\/createobject\/\" \/>\n<meta property=\"og:site_name\" content=\"The AMPscript Guide\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-21T15:47:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-06T01:18:20+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ampscript.guide\/#website\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"The AMPscript Guide\",\"description\":\"The Definitive Scripting Manual for Salesforce Marketing Cloud\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/ampscript.guide\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/createobject\/#webpage\",\"url\":\"https:\/\/ampscript.guide\/createobject\/\",\"name\":\"The AMPscript Guide - CreateObject\",\"isPartOf\":{\"@id\":\"https:\/\/ampscript.guide\/#website\"},\"datePublished\":\"2018-04-21T15:47:45+00:00\",\"dateModified\":\"2021-04-06T01:18:20+00:00\",\"author\":{\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\"},\"breadcrumb\":{\"@id\":\"https:\/\/ampscript.guide\/createobject\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ampscript.guide\/createobject\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ampscript.guide\/createobject\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/createobject\/\",\"url\":\"https:\/\/ampscript.guide\/createobject\/\",\"name\":\"CreateObject\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\",\"name\":\"dev\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","_links":{"self":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31374"}],"collection":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/comments?post=31374"}],"version-history":[{"count":0,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31374\/revisions"}],"wp:attachment":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/media?parent=31374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/categories?post=31374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/tags?post=31374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}