{"id":2139,"date":"2016-02-04T05:55:07","date_gmt":"2016-02-04T05:55:07","guid":{"rendered":"http:\/\/www.ericwhite.com\/home2\/bm8qcmjy\/public_html\/blog\/?page_id=2139"},"modified":"2016-02-04T05:55:38","modified_gmt":"2016-02-04T05:55:38","slug":"openxmlpart-getpartbyrelationshiptype","status":"publish","type":"page","link":"https:\/\/www.ericwhite.com\/blog\/openxmlpart-getpartbyrelationshiptype\/","title":{"rendered":"OpenXmlPart.getPartByRelationshipType (relationshipType)"},"content":{"rendered":"<p><span class=\"Back\"><a class=\"Back\" href=\"https:\/\/www.ericwhite.com\/blog\/open-xml-sdk-for-javascript\/\">Return to the<br \/>Open XML SDK for JavaScript<br \/>Developer Center<\/a><\/span>Gets the part with the specified relationship type. If there is more than one part with the specified relationship type, this function returns the first one. openXml.relationshipTypes contains a list of the most common relationship types.<\/p>\n<h1>Syntax<\/h1>\n<pre>\r\n    var part = OpenXmlPart.getPartByRelationshipType(relationshipType);\r\n<\/pre>\n<h1>Arguments<\/h1>\n<pre>\r\n    relationshipType: An string that contains the relationship type.\r\n<\/pre>\n<h1>Return Value<\/h1>\n<pre>\r\n    Returns an OpenXmlPart object. If there is no part related with the specified relationship type, this function returns null.\r\n<\/pre>\n<h1>Usage<\/h1>\n<pre>\r\n    var commentsPart = doc.mainDocumentPart()\r\n    .getPartByRelationshipType(openXml.relationshipTypes.wordprocessingComments);\r\n<\/pre>\n<h1>Example<\/h1>\n<pre>\r\n\/\/ Open a document that contains comments.\r\nvar doc = new openXml.OpenXmlPackage(withComments_flatOpc);\r\nvar commentsPart = doc\r\n    .mainDocumentPart()\r\n    .getPartByRelationshipType(openXml.relationshipTypes.wordprocessingComments);\r\n\/\/ Note that there are convenience functions that retrieve the most commonly used parts.\r\nvar commentsPart2 = doc.mainDocumentPart().wordprocessingCommentsPart();\r\nvar o = [];\r\nif (commentsPart !== null) {\r\n    o.push(\"Found the part, uri = \" + commentsPart.uri);\r\n}\r\nif (commentsPart2 !== null) {\r\n    o.push(\"Also found uri = \" + commentsPart2.uri);\r\n}\r\nreturn { output: o };\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Return to theOpen XML SDK for JavaScriptDeveloper CenterGets the part with the specified relationship type. If there is more than one part with the specified relationship type, this function returns the first one. openXml.relationshipTypes contains a list of the most common relationship types. Syntax var part = OpenXmlPart.getPartByRelationshipType(relationshipType); Arguments relationshipType: An string that contains the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_s2mail":"","footnotes":""},"class_list":["post-2139","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/comments?post=2139"}],"version-history":[{"count":2,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2139\/revisions"}],"predecessor-version":[{"id":2141,"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/pages\/2139\/revisions\/2141"}],"wp:attachment":[{"href":"https:\/\/www.ericwhite.com\/blog\/wp-json\/wp\/v2\/media?parent=2139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}