{"id":20343,"date":"2019-08-28T12:01:58","date_gmt":"2019-08-28T12:01:58","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=20343"},"modified":"2019-08-28T12:05:54","modified_gmt":"2019-08-28T12:05:54","slug":"access-source-element-of-relationship-while-creating-new-records-in-resco-mobile-app","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2019\/08\/access-source-element-of-relationship-while-creating-new-records-in-resco-mobile-app\/","title":{"rendered":"How to access Source Element of Relationship while creating new records in Resco Mobile App"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p style=\"text-align: justify;\">Recently we had a business requirement in which we needed to create child records of <strong>Account<\/strong> entity from Parent <strong>Account<\/strong> record with pre-populated <strong>\u2018Account Type\u2019<\/strong> field.<\/p>\n<p style=\"text-align: justify;\">For example, we have an Option Set field (<strong>\u2018Account Type\u2019<\/strong> with four options Architects, Customers, Designers and Drafters) and four Entity Lists added on the <strong>Account<\/strong> Entity Form. Each Entity List has filter based on the \u2018Account Type\u2019 Option Set field and we want to pre-populate the \u2018Account Type\u2019 field on the child <strong>Account<\/strong>, when it is being created from one of the Entity Lists.<\/p>\n<p style=\"text-align: justify;\">In <strong>Html<\/strong> (using JSBridge reference), we can get access to the relationship of the record (i.e. from which it is being created). And from that relationship we can retrieve the \u2018Source Element\u2019 of that record. This \u2018Source Element\u2019 provides the name of the \u2018Entity List\u2019 from which the record is being created. And we can use this for populating fields (i.e. \u2018Account Type\u2019) on <strong>Account<\/strong>. Also we can get access to all the properties of the parent record in relationship.<\/p>\n<p><strong><em>Note: If an entity record is created directly (i.e. not from any Entity List), then Source Element will be empty.<\/em><\/strong><\/p>\n<p>In order to achieve this we have followed the below steps:<\/p>\n<p><strong>1<\/strong>. We have added \u2018Account Type\u2019 field on the \u2018Entity Form\u2019 of <strong>Account<\/strong> entity. And renamed the \u2018Entity Lists\u2019 as the options of the \u2018Account Type\u2019 field as below.<\/p>\n<p>Please refer below screenshot:<\/p>\n<p style=\"padding-left: 40px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-20344\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/1Resco-Mobile-App.png\" alt=\"\" width=\"581\" height=\"513\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/1Resco-Mobile-App.png 581w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/1Resco-Mobile-App-300x265.png 300w\" sizes=\"(max-width: 581px) 100vw, 581px\" \/><\/p>\n<p><strong>2<\/strong>. Then we have developed an <strong>Html<\/strong> file with <strong>JSBridge<\/strong> reference (Code is specified below) for retrieving the relationship of the record (from which it is being created) and populated the value of the \u2018Account Type\u2019 field based \u2018Source Element\u2019 of that relationship.<\/p>\n<p>Please refer below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-20345\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/2Resco-Mobile-App.png\" alt=\"Resco Mobile App\" width=\"940\" height=\"542\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/2Resco-Mobile-App.png 940w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/2Resco-Mobile-App-300x173.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/2Resco-Mobile-App-768x443.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/2Resco-Mobile-App-660x381.png 660w\" sizes=\"(max-width: 940px) 100vw, 940px\" \/><\/p>\n<blockquote><p><strong><em>Note: \u2018entityForm\u2019 is an \u2018Object\u2019 which is retrieved from \u2018RequestObject\u2019 method of JSBridge reference file and \u2018entityForm.relationship.sourceUIElement\u2019 returns the \u2018Name\u2019 of the \u2018EntityList\u2019 defined\/specified on the Entity Form. Also you will get access to all properties of the Parent record in entityForm.relationship object.<\/em><\/strong><\/p><\/blockquote>\n<p><strong>3<\/strong>. We have added the above Html file in <strong>Offline Html<\/strong> of Resco Mobile App. And then created an IFrame on \u2018Entity Form\u2019 of <strong>Account<\/strong> entity (for populating the \u2018Account Type\u2019 when the record is created from a specific Entity List of its Parent <strong>Account) <\/strong>and published the Project.<\/p>\n<p>Please refer below screenshots:<\/p>\n<p>Offline HTML:<\/p>\n<p style=\"padding-left: 40px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-20346\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/3Resco-Mobile-App.png\" alt=\"Resco Mobile App\" width=\"603\" height=\"327\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/3Resco-Mobile-App.png 603w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/3Resco-Mobile-App-300x163.png 300w\" sizes=\"(max-width: 603px) 100vw, 603px\" \/><\/p>\n<p>IFrame of Account Entity:<\/p>\n<p style=\"padding-left: 120px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-20347\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/4Resco-Mobile-App.png\" alt=\"Resco Mobile App\" width=\"440\" height=\"329\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/4Resco-Mobile-App.png 440w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/4Resco-Mobile-App-300x224.png 300w\" sizes=\"(max-width: 440px) 100vw, 440px\" \/><\/p>\n<p><strong>4<\/strong>. After publishing the project, we have synced the Resco Mobile App and navigated to the <strong>Account<\/strong> entity record for adding a new child <strong>Account<\/strong> from \u2018Customers\u2019 Entity List.<\/p>\n<p>Please refer below screenshots:<\/p>\n<p style=\"padding-left: 120px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-20348\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/5Resco-Mobile-App.png\" alt=\"Resco Mobile App\" width=\"434\" height=\"613\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/5Resco-Mobile-App.png 434w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/5Resco-Mobile-App-212x300.png 212w\" sizes=\"(max-width: 434px) 100vw, 434px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 120px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-20349\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/6Resco-Mobile-App.png\" alt=\"Resco Mobile App\" width=\"430\" height=\"611\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/6Resco-Mobile-App.png 430w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/6Resco-Mobile-App-211x300.png 211w\" sizes=\"(max-width: 430px) 100vw, 430px\" \/><\/p>\n<p>After clicking the plus button (i.e. +), the new <strong>Account<\/strong> entity form is loaded, and the value of the \u2018Account Type\u2019 was populated on the form.<\/p>\n<p>Please refer below screenshot:<\/p>\n<p style=\"padding-left: 120px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-20350\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/7Resco-Mobile-App.png\" alt=\"Resco Mobile App\" width=\"431\" height=\"613\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/7Resco-Mobile-App.png 431w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/7Resco-Mobile-App-211x300.png 211w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/><\/p>\n<p>And after saving the record, it is shown in \u2018Customers\u2019 Entity List.<\/p>\n<p>Please refer below screenshot:<\/p>\n<p style=\"padding-left: 120px;\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-20351\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/8Resco-Mobile-App.png\" alt=\"Resco Mobile App\" width=\"431\" height=\"612\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/8Resco-Mobile-App.png 431w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/08\/8Resco-Mobile-App-211x300.png 211w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>You can use relationship property of \u2018Entity Form Object\u2019 for retrieving \u2018Source Element\u2019 in script (with JSBridge reference) while creating new record from Entity list in Resco Mobile App.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Recently we had a business requirement in which we needed to create child records of Account entity from Parent Account record with pre-populated \u2018Account Type\u2019 field. For example, we have an Option Set field (\u2018Account Type\u2019 with four options Architects, Customers, Designers and Drafters) and four Entity Lists added on the Account Entity Form.\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2019\/08\/access-source-element-of-relationship-while-creating-new-records-in-resco-mobile-app\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":20361,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[48],"tags":[1447],"class_list":["post-20343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-resco-mobile-crm","tag-resco-mobile-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/20343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=20343"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/20343\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/20361"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=20343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=20343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=20343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}