{"id":31372,"date":"2018-04-21T15:47:45","date_gmt":"2018-04-21T15:47:45","guid":{"rendered":"https:\/\/ampscript.guide\/functions-addobjectarrayitem\/"},"modified":"2021-04-06T01:18:20","modified_gmt":"2021-04-06T01:18:20","slug":"addobjectarrayitem","status":"publish","type":"post","link":"https:\/\/ampscript.guide\/addobjectarrayitem\/","title":{"rendered":"AddObjectArrayItem"},"content":{"rendered":"<h2>AddObjectArrayItem<\/h2>\n<p>This function adds an object to a <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> array.<\/p>\n<h3>Arguments<\/h3>\n<p><code>AddObjectArrayItem(1,2,3)<\/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\">API Object<\/td>\n<td style=\"text-align: left\">True<\/td>\n<td style=\"text-align: left\">The API Object that contains the array<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">2<\/td>\n<td style=\"text-align: left\">String<\/td>\n<td style=\"text-align: left\">True<\/td>\n<td style=\"text-align: left\">The array property associated with the item to be added<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">3<\/td>\n<td style=\"text-align: left\">String<\/td>\n<td style=\"text-align: left\">True<\/td>\n<td style=\"text-align: left\">The item to add to the array<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Example<\/h3>\n<p>The following example retrieves all of the <code>DataFolder<\/code> objects in a Marketing Cloud account.  The <code>AddObjectArrayItem()<\/code> lines are used to add the object attributes to retrieve in the request (<code>ID<\/code> and <code>Name<\/code>).<\/p>\n<pre><code>%%[\n\nvar @rr, @ID, @Name\nset @rr = CreateObject(\"RetrieveRequest\")\nSetObjectProperty(@rr, \"ObjectType\", \"DataFolder\")\nAddObjectArrayItem(@rr, \"Properties\", \"ID\")\nAddObjectArrayItem(@rr, \"Properties\", \"Name\")\n\nset @dataFolders = InvokeRetrieve(@rr, @rrStatus, @rrRequestID)\n\noutput(concat(\"rrStatus: \", @rrStatus))\noutput(concat(\"&lt;br&gt;rrRequestID: \", @rrRequestID))\n\nfor @i = 1 to RowCount(@dataFolders) do\n\n  set @dataFolder = Row(@dataFolders, @i)\n  set @ID = Field(@dataFolder, \"ID\")\n  set @Name = Field(@dataFolder, \"Name\")\n\n  output(concat(\"&lt;br&gt;ID: \", @ID, \", Name: \", @Name))\n\nnext @i\n\n]%%<\/code><\/pre>\n<h4>Output<\/h4>\n<pre><code>rrStatus: OK\nrrRequestID: 9a64813a-0aa1-497b-8cb6-c6030531b3b1\nID: 13738, Name: my emails\nID: 13739, Name: simple automated emails\nID: 13740, Name: my templates\nID: 13741, Name: my lists\nID: 13742, Name: my tracking\nID: 13743, Name: my contents\nID: 13744, Name: my documents\nID: 13745, Name: my surveys\nID: 13746, Name: my images\nID: 13747, Name: Portfolio\nID: 13748, Name: my groups\nID: 13749, Name: my subscribers\nID: 13750, Name: Forward to a Friend\nID: 13751, Name: Forward to a Friend\nID: 13752, Name: Suppression Lists\nID: 13753, Name: Triggered Sends\nID: 13754, Name: User-Initiated\nID: 13755, Name: Data Extensions\nID: 13756, Name: Publication Lists\nID: 13757, Name: my microsites\nID: 13758, Name: microsite layouts\nID: 13760, Name: Query\nID: 13761, Name: Data Filters\nID: 13762, Name: Filter\nID: 13763, Name: Social\nID: 13764, Name: A\/B Testing\nID: 13765, Name: my workflows\nID: 25111, Name: Journey Builder Sends\nID: 58137, Name: HiddenCategory\nID: 58138, Name: SystemHiddenDataFilters\nID: 58139, Name: SystemHiddenDataFiltersForGE\nID: 58140, Name: SystemHiddenFilterActivities\nID: 58141, Name: SystemHiddenFilterActivitiesForGE\nID: 58142, Name: my automations\nID: 58547, Name: Salesforce Single Sends\nID: 58548, Name: Salesforce Mass Sends\nID: 58549, Name: Salesforce Sends\nID: 58550, Name: Salesforce Data Extensions<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>AddObjectArrayItem This function adds an object to a Marketing Cloud API Object array. Arguments AddObjectArrayItem(1,2,3) Ordinal Type Required Description 1 API Object True The API Object that contains the array 2 String True The array property associated with the item to be added 3 String True The item to add to the array Example The [&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 - AddObjectArrayItem<\/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\/addobjectarrayitem\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The AMPscript Guide - AddObjectArrayItem\" \/>\n<meta property=\"og:description\" content=\"AddObjectArrayItem This function adds an object to a Marketing Cloud API Object array. Arguments AddObjectArrayItem(1,2,3) Ordinal Type Required Description 1 API Object True The API Object that contains the array 2 String True The array property associated with the item to be added 3 String True The item to add to the array Example The [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ampscript.guide\/addobjectarrayitem\/\" \/>\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\/addobjectarrayitem\/#webpage\",\"url\":\"https:\/\/ampscript.guide\/addobjectarrayitem\/\",\"name\":\"The AMPscript Guide - AddObjectArrayItem\",\"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\/addobjectarrayitem\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ampscript.guide\/addobjectarrayitem\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ampscript.guide\/addobjectarrayitem\/#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\/addobjectarrayitem\/\",\"url\":\"https:\/\/ampscript.guide\/addobjectarrayitem\/\",\"name\":\"AddObjectArrayItem\"}}]},{\"@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\/31372"}],"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=31372"}],"version-history":[{"count":0,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31372\/revisions"}],"wp:attachment":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/media?parent=31372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/categories?post=31372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/tags?post=31372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}