<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: How to Change Content of flowfile  provided property name dynamically. in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/How-to-Change-Content-of-flowfile-provided-property-name/m-p/387740#M246413</link>
    <description>&lt;P&gt;Used Option2 - Groovy script for this scenario.&lt;/P&gt;</description>
    <pubDate>Fri, 10 May 2024 03:39:52 GMT</pubDate>
    <dc:creator>mohdriyaz</dc:creator>
    <dc:date>2024-05-10T03:39:52Z</dc:date>
    <item>
      <title>How to Change Content of flowfile  provided property name dynamically.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-Change-Content-of-flowfile-provided-property-name/m-p/386862#M246165</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to change the flowfile content (json format) using UpdateRecord by providing property (to be change) from attribute.&lt;/P&gt;&lt;P&gt;Here is the flowfile content&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mohdriyaz_0-1713685742848.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/40359i276B1CD976E412BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mohdriyaz_0-1713685742848.png" alt="mohdriyaz_0-1713685742848.png" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;here is the flowfile attribute&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mohdriyaz_1-1713685829562.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/40360iAFCE392DE0D493B8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mohdriyaz_1-1713685829562.png" alt="mohdriyaz_1-1713685829562.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to change the value of "id"&amp;nbsp; in flowfile content using UpdateRecords like this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;( WHICH IS NOT WORKING )&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mohdriyaz_2-1713685901848.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/40361iBF13E8B845E47FF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mohdriyaz_2-1713685901848.png" alt="mohdriyaz_2-1713685901848.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works but add a new property to existing flow file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mohdriyaz_0-1713686303606.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/40363i6BC1C5D5E11EE6E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mohdriyaz_0-1713686303606.png" alt="mohdriyaz_0-1713686303606.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mohdriyaz_1-1713686349403.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/40364i6C6F9666800CF881/image-size/medium?v=v2&amp;amp;px=400" role="button" title="mohdriyaz_1-1713686349403.png" alt="mohdriyaz_1-1713686349403.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here "id" got change because i provided "/id" (hardcoded property name) , i need same functionality to work with "/${col_name}"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Pointers ... ?????&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Riyaz&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 08:22:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-Change-Content-of-flowfile-provided-property-name/m-p/386862#M246165</guid>
      <dc:creator>mohdriyaz</dc:creator>
      <dc:date>2024-04-21T08:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Content of flowfile  provided property name dynamically.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-Change-Content-of-flowfile-provided-property-name/m-p/386867#M246166</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/109451"&gt;@mohdriyaz&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;I dont think you can accomplish this using the UpdateRecord processor as the added property has to be valid record path where the fields are specified explicitly. I can think of two options to do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1- Using JoltTransformJson:&amp;nbsp; you can use "modify-overwrite-beta" spec to update a field but since the spec allows expression language and flowfile attribute evaluation you can reference the field name in the spec dynamically. In this case the spec will look like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
    	"${col_name}":"9999"
    }
  }
]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2-Using&amp;nbsp; ExecuteScript: You can write custom script like groovy, python ...etc.&amp;nbsp; (depending on what Nifi version you are using) the script will basically read the json content into some dictionary or hashmap structure, read the flowfile attribute "col_name" into a variable and use that variable as a key to the field that you need to change in the json dictionary. Finally write then new content to the flowfile and pass to the success relationship. You can do error handling there as well and send any errors to the failure relationship.&amp;nbsp; For more info on how to update flowfile content using ExecuteScript processor please refer to the "&lt;STRONG&gt;Reading and writing to/from a flow file&lt;/STRONG&gt;" section under this link:&amp;nbsp; &lt;A href="https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-2/ta-p/249018" target="_blank"&gt;https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-2/ta-p/249018&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you find this is helpful please accept solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Apr 2024 12:53:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-Change-Content-of-flowfile-provided-property-name/m-p/386867#M246166</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2024-04-21T12:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to Change Content of flowfile  provided property name dynamically.</title>
      <link>https://community.cloudera.com/t5/Support-Questions/How-to-Change-Content-of-flowfile-provided-property-name/m-p/387740#M246413</link>
      <description>&lt;P&gt;Used Option2 - Groovy script for this scenario.&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 03:39:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/How-to-Change-Content-of-flowfile-provided-property-name/m-p/387740#M246413</guid>
      <dc:creator>mohdriyaz</dc:creator>
      <dc:date>2024-05-10T03:39:52Z</dc:date>
    </item>
  </channel>
</rss>

