Toggle menu

iCM_obj_articleUpdate

All articles in iCM are identified by a unique ID. When using iCM_obj_articleUpdate, if the supplied ArticleID already exists, that article will be updated. If the ArticleID is blank (or set as zero) a new article will be created.

When creating a new article, you can either provide the ArticleStruct, or use iCM_obj_articleGet with ArticleTemplateID to return an empty ArticleStruct which you will then have to merge with your new article data.

ArticleStruct.ArticleID, ArticleStruct.ArticleHeading, ArticleStruct.ArticleParentID and ArticleStruct.ArticleTemplateID must be set. Other elements must be provided, but if left blank will assume sensible defaults.

Both the username and password should be provided using the default credentials of an API Key. See "Supplying Default Credentials" in URLs, Keys and Authentication.

Properties

NameTypeDescription
CSUserNameString, requiredThe username of the iCM user inserting/updating the article. This should be provided using the default credentials of an API Key
CSUserPasswordString, requiredThe password of the iCM user inserting/updating the article. This should be provided using the default credentials of an API Key
SignificantChangeBoolean, optionalWhether or not this update should be flagged as a significant change
VersionNotesString, optionalNotes added to the article version history when this update is made. There's a maximum length of 256 characters
ArticleStructObject, requiredSee below

Required ArticleStruct Properties

The following properties must be defined in the ArticleStruct object. Those marked as required must have a value. Others are required, but their values may be an empty string.

NameTypeDescription
ArticleDateDateTimeThe creation date and time of the article. This will always be "now" but needs to be supplied as an empty string
ArticleIDInteger, RequiredThe ID of the article to be updated. Set as 0 to create a new article
ArticleHeadingString, RequiredThe article's heading text
ArticleTemplateIDInteger, RequiredThe ID of the template the article will use
ArticleParentIDInteger, RequiredThe article ID beneath which the article will be created/updated
ArticleIntroTextStringThe article introductory text
ArticleDisplayStringEither "on" or "off". Defaults to "on" (the article is visible on the site)
ArticleDisplayDateDateTimeThe date and time from which the article will display. Defaults to the article create date/time if left blank. Dates in an ISO 8601 combined format, ie "2018-02-01T00:00:00Z"
ArticleDisplayEDateDateTimeThe date and time until which the article will display. Defaults to 100 years in the future if left blank. Dates in an ISO 8601 combined format, ie "2018-02-01T00:00:00Z"
ArchiveableBooleanIf true the article will be archived on the ArchiveDate. Defaults to false
ArchiveDateDateTime, Required if Archiveable:trueThe date on which the article will be archived. Dates in an ISO 8601 combined format, ie "2018-02-01T00:00:00Z"
ArchiveParentIDInteger, Required if Archiveable:trueThe parent beneath which the article will move on its archive date
ArticleTextStringThe article body text. HTML will be tidied, and unsupported HTML elements removed, following the standard behaviour of the article editor described in Text Editor Configuration
ArticleReviewDateDateTimeThe date and time on which the article update is due (whether explicitly set or calculated form the ReviewInterval). Leave blank for no review. Dates in an ISO 8601 combined format, ie "2018-02-01T00:00:00Z"
ArticleReviewIntervalStringThe number of hours between reviews. Leave blank for no review

Optional ArticleStruct Properties

All of the following properties can be optionally included in the ArticleStruct object.

NameTypeDescription
ArticleSummaryStringThe article summary text
ArticleTextAdditionalObjectAdditional text blocks, other than the body text, are returned as an object in the format {"BLOCKID": "<p>Text</p>"}
BoostedKeywordsStringA comma separated list of the article's boosted keywords
BoostValueIntegerThe search boost value, -10 to +10
ChildArticleIDsStringA comma separated list of child article IDs. If manual ordering of articles is enabled this property can be used to reorder the child articles. Otherwise ignored
ExtensionObjectThe article's extension data. This MUST be supplied if the article's template specifies extension data
FriendlyURLStringThe article's friendly URL
LocationIndexIntegerThe ordering position where this article will be inserted within its siblings below the parent article if manual of articles is enabled. Otherwise ignored
OwnerIDIntegerThe ID of an iCM user to set as the article owner. Defaults to the ID of the user creating the article (ie the user provided by the API Key)
UpdateNotesStringNotes visible on the article schedule tab and included in the update due email if ArticleReviewDate or ArticleReviewInterval have been set
SecureUserListStringA comma separated list of site user group IDs this article should be secured to
RelatedMediaListStringA comma separated list of content IDs to relate to this article
RelatedLinkListStringA comma separated list of content IDs to relate to this article
RelatedMetaDataListStringA comma separated list of content IDs to relate to this article
RelatedArticleListStringA comma separated list of content IDs to relate to this article
RelatedPollListStringA comma separated list of content IDs to relate to this article
RelatedForumListStringA comma separated list of content IDs to relate to this article
RelatedFeatureListStringA comma separated list of content IDs to relate to this article
RelatedRackListStringA comma separated list of content IDs to relate to this article
RelatedProductListStringA comma separated list of content IDs to relate to this article
RelatedEventListStringA comma separated list of content IDs to relate to this article
RelatedFormListStringA comma separated list of content IDs to relate to this article

Returns

If the request was successful the result data object will contain an object called CONTENT which includes the article ID and another called STATE indicating the article was created/updated successfully.

{
    "id": 106,
    "result": {
        "CONTENT": {
            "Status": "Live",
            "ArticleID": 3424
        },
        "STATE": {
            "Status": "ACCESS GRANTED"
        }
    },
    "jsonrpc": "2.0"
}

Example 1

In this example the core properties are provided in the ArticleStruct. ArticleID is 0 because we are creating a new article. Setting the ArticleID of an existing article would update that article. As with all iCM_ requests, the parameters are provided in the "attributes" object and the user details by the apiKey.

Make a call to iCM_obj_articleGet with the desired ArticleTemplateID to return a default structure for that template type.

function(params, credentials) {
    let createArticle = this.callWorkerMethod("icmapi", "iCM_obj_articleUpdate", {
        "attributes": {
            "ArticleStruct": {
                "ArticleDate": "",
                "ArticleID": 0,
                "ArticleHeading": "My New Article",
                "ArticleTemplateID": 1,
                "ArticleParentID": 3424,
                "ArticleIntroText": "",
                "ArticleDisplay": "",
                "ArticleDisplayDate": "",
                "ArticleDisplayEDate": "",
                "Archiveable": "",
                "ArchiveDate": "",
                "ArchiveParentID": "",
                "ArticleText": "",
                "ArticleReviewDate": "",
                "ArticleReviewInterval": ""
            }
        }
    }, {
        "options": {
            "apiKey": "<Your API Key>"
        }
    });
    return createArticle;
}

Example 2

When updating an existing article you can either supply the ArticleStruct as in example 1, or call iCM_obj_articleGet and an ArticleID to return the content of an existing article.

In this example we are fetching article ID 25 and updating its heading text.

function(params, credentials) {
    let articleData = this.callWorkerMethod("icmapi", "iCM_obj_articleGet", {
        "attributes": {
            "ArticleID": 25,
            "GetExtensionData": true
        }
    });
    articleData.CONTENT.ArticleHeading = "Here's my new heading";
    let createArticle = this.callWorkerMethod("icmapi", "iCM_obj_articleUpdate", {
        "attributes": {
            "ArticleStruct": articleData.CONTENT
        }
    }, {
        "options": {
            "apiKey": "<Your API Key>"
        }
    });
    return createArticle;
}

Last modified on 4 January 2024

Share this page

Facebook icon Twitter icon email icon

Print

print icon