Member since 
    
	
		
		
		06-14-2022
	
	
	
	
	
	
	
	
	
	
	
	
	
	
			
      
                62
            
            
                Posts
            
        
                2
            
            
                Kudos Received
            
        
                0
            
            
                Solutions
            
        
			
    
	
		
		
		12-11-2022
	
		
		09:26 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 Hi Team,     Need help. I have below two part.     1. merge the original Response with the API Response     Original response  [{  "code": "100016",  "Date": "2022-09-22"  }, {  "code": "100017",  "Date": "2022-09-02"  },  {  "code": "100018",  "Date": "2022-09-02"  },  {  "code": "100019",  "Date": "2022-09-02"  }  ]     API Response:  [{  "Record": "Record 3",  "Description": "Processing failed due Internal Server Error."  }, {  "Record": "Record 4",  "Description": "Processing failed due to error in record: 3"  }]     Required output:  {  "RequestPayload": [{  "code": "100016",  "Date": "2022-09-22"  }, {  "code": "100017",  "Date": "2022-09-02"  },  {  "code": "100018",  "Date": "2022-09-02"  },  {  "code": "100019",  "Date": "2022-09-02"  }  ],  "ApiResponse": [{  "Record": "Record 3",  "Description": "Processing failed due Internal Server Error."  }, {  "Record": "Record 4",  "Description": "Processing failed due to error in record: 3"  }]  }     After getting the above output I need to mapped the json objects as below  input:     {  "RequestPayload": [{  "code": "100016",  "Date": "2022-09-22"  }, {  "code": "100017",  "Date": "2022-09-02"  },  {  "code": "100018",  "Date": "2022-09-02"  },  {  "code": "100019",  "Date": "2022-09-02"  }  ],  "ApiResponse": [{  "Record": "Record 3",  "Description": "Processing failed due Internal Server Error."  }, {  "Record": "Record 4",  "Description": "Processing failed due to error in record: 3"  }]  }     I am getting below output:     [  "{\"code\":\"100018\",\"Date\":\"2022-09-22\"}",  "{\"code\":\"100019\",\"Date\":\"2022-09-02\"}"  ]     Expected Output:  [{  "code": "100018",  "Date": "2022-09-22",  "Record": "Record 3",  "Description": "Processing failed due Internal Server Error."."  }, {  "code": "100019",  "Date": "2022-09-02",  "Record": "Record 4",  "Description": "Processing failed due to error in record: 3"  }    ]     For that I am using below groovy Script:  import org.apache.commons.io.IOUtils  import java.nio.charset.StandardCharsets  import groovy.json.*  import java.util.ArrayList  def flowFile = session.get()  if(!flowFile) return  try {  flowFile = session.write(flowFile,  { inputStream, outputStream ->  def text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)  def obj = new JsonSlurper().parseText(text)  def final1 = []  int j = obj.RequestPayload.size()  for (int i=0;i<j;i++){  index = i+1  def rec = 'Record ' + index  if (rec in obj.ApiResponse.Record){    final1.add(JsonOutput.toJson(obj.RequestPayload[i]))  }  }  def response1 = JsonOutput.toJson(final1)  outputStream.write(JsonOutput.prettyPrint(response1).getBytes(StandardCharsets.UTF_8))  } as StreamCallback)    session.transfer(flowFile, REL_SUCCESS)  } catch(Exception e) {  log.error('Error during JSON operations', e)  session.transfer(flowFile, REL_FAILURE)  }     Can you please help. I am not familiar with groovy but i want to get the desired output with groovy script. Thanks in Advance          
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
		
			
				
						
							Labels:
						
						
		
			
	
					
			
		
	
	
	
	
				
		
	
	
- Labels:
 - 
						
							
		
			Apache NiFi
 
			
    
	
		
		
		12-10-2022
	
		
		06:51 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 Hi @MattWho , I did lot of investigation on the same but was not sure merge record can do that. Thanks a lot for your help. 
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
			
    
	
		
		
		12-10-2022
	
		
		06:46 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 Hi @Faerballert ,   Thank you so much. I tried it earlier the same but not sure why it were not working.  some of my fields contains null values. But instead of null I want the empty string in the same jolt. Can we do that? is there any option to do the same.    
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
			
    
	
		
		
		12-09-2022
	
		
		02:30 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 I have below input:     [  {  "seq_no": 18,  "Id": 174052,  "Date": "2021-12-26T00:00:00Z"  },  {  "seq_no": 19,  "Id": 174052,  "Date": "2021-12-26T00:00:00Z"  }  ]     Jolt Spec:     [  {  "operation": "modify-overwrite-beta",  "spec": {  "*": {  "seq_no": "=toString",  "Date": "=substring(@(1,REVISION_IND),0,10)"  }  }  },  {  "operation": "shift",  "spec": {  "*": {  "seq_no": "[&1].seq_no",  "Id": "[&1].Id",  "Date": "[&1].Date"  }  }  },  {  "operation": "shift",  "spec": {  "*": "data"  }  },  {  "operation": "default",  "spec": {  "header": {  "submit": "true",  "comments": "3"  }  }  }  ]     Output:  {  "data" : [ {  "seq_no" : "18",  "Id" : 174052,  "Date" : "2021-12-26T00:00:00Z"  }, {  "seq_no" : "19",  "Id" : 174052,  "Date" : "2021-12-26T00:00:00Z"  } ],  "header" : {  "submit" : "true",  "comments" : "3"  }  }     Desired Output:     {  "header" : {  "submit" : "true",  "comments" : "3"  },  "data" : [ {  "seq_no" : "18",  "Id" : 174052,  "Date" : "2021-12-26T00:00:00Z"  }, {  "seq_no" : "19",  "Id" : 174052,  "Date" : "2021-12-26T00:00:00Z"  } ]  }     Can you please help how I will get the header part and then the data. I used sort but it's not helping me. Appreciate your help. Thank you. 
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
		
			
				
						
							Labels:
						
						
		
			
	
					
			
		
	
	
	
	
				
		
	
	
- Labels:
 - 
						
							
		
			Apache NiFi
 
			
    
	
		
		
		12-07-2022
	
		
		10:19 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 Hi Team,      can anyone help  
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
			
    
	
		
		
		12-06-2022
	
		
		10:20 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 I am fetching data from table for employees and each employees has maximum 7 Records. I am splitting data based on the IDs and week number column. I need to merge the data in such a way that each flow file contains 100 records and all the records of each employees comes into that flow file  for example  My flow file already has 98 records and next employee has 7 records so, that employee's data should not be the part of that flow file. It should come in next flow file likewise.....  While merging the FFs order is also important.  How can I do that. I am not familiar with all the processors of NiFi 
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
		
			
				
						
							Labels:
						
						
		
			
	
					
			
		
	
	
	
	
				
		
	
	
- Labels:
 - 
						
							
		
			Apache NiFi
 
			
    
	
		
		
		12-06-2022
	
		
		04:10 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 Thank you so much @Faerballert  
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
			
    
	
		
		
		12-01-2022
	
		
		10:23 PM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 Hi Team, can you please help.    
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
			
    
	
		
		
		12-01-2022
	
		
		12:49 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 I am getting below input flow file:     Input:  [ {  "original" : {  "Id" : "100008",  "Date" : "2022-09-22"  },  "enrichment" : {  "Record" : "Record 11",  "Description" : "Invalid values for Id or Date"  }  }, {  "original" : {  "Id" : "100009",  "Date" : "2022-09-02"  },  "enrichment" : {  "Record" : "Record 2",  "Description" : "Invalid values for Id or Date"  }  } ]     Expected output:  [  {  "original" : {  "Id" : "100009",  "Date" : "2022-09-02"  },  "enrichment" : {  "Record" : "Record 2",  "Description" : "Invalid values for Id or Date"  }  }  ]     and Output I am getting is the below using Groovy script:  [  "{\"original\":{\"Id\":\"100009\",\"Date\":\"2022-09-02\"},\"enrichment\":{\"Record\":\"Record 2\",\"Description\":\"Invalid values for Id or Date\"}}"  ]        Groovy Script:  import org.apache.commons.io.IOUtils  import java.nio.charset.StandardCharsets  import groovy.json.*  import java.util.ArrayList  def flowFile = session.get()  if(!flowFile) return  try {  flowFile = session.write(flowFile,  { inputStream, outputStream ->  def text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)  def obj = new JsonSlurper().parseText(text)  def final1 = []  int j = obj.text.size()  for (int i=0;i<j;i++){  index = i+1  def rec = 'Record ' + index  if (rec in obj.enrichment.Record){    final1.add(JsonOutput.toJson(obj[i]))  }  }  response1 = JsonOutput.toJson(final1)  outputStream.write(response1.getBytes(StandardCharsets.UTF_8))  } as StreamCallback)    session.transfer(flowFile, REL_SUCCESS)  } catch(Exception e) {  log.error('Error during JSON operations', e)  session.transfer(flowFile, REL_FAILURE)  }        Can you please help to can I get the formatted array of json output of this groovy Script. I am new to groovy 
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
		
			
				
						
							Labels:
						
						
		
			
	
					
			
		
	
	
	
	
				
		
	
	
- Labels:
 - 
						
							
		
			Apache NiFi
 
			
    
	
		
		
		11-29-2022
	
		
		01:21 AM
	
	
	
	
	
	
	
	
	
	
	
	
	
	
		
	
				
		
			
					
				
		
	
		
					
							 Hi Team,     I have below requirement,     my flow file contains below data:  [ {  {  "ID" : "100000",  "Date" : "2022-09-22",  "Start Time" : "08:00",  "End Time" : "14:00",    }, {  "ID" : "100001",  "Date" : "2022-09-02",  "Start Time" : "08:00",  "End Time" : "14:00",  },  {  "ID" : "100002",  "Date" : "2022-09-02",  "Start Time" : "08:00",  "End Time" : "14:00",  }  } ]     [ {"res_data" : {  "Record" : "Record 2",  "Description" : "Invalid values for ID or Date"  },  {  "Record" : "Record 3",  "Description" : "Invalid values for ID or Date"  }} ]     And the requirement is:  if concatenate ('Record' with index of array of json object == res_data.Record   then it should return  {  {  "ID" : "100001",  "Date" : "2022-09-02",  "Start Time" : "08:00",  "End Time" : "14:00",  "Record" : "Record 2",  "Description" : "Invalid values for ID or Date"  }  } and so on     else  {  "ID" : "100000",  "Date" : "2022-09-02",  "Start Time" : "08:00",  "Time Out" : "14:00",  "End Time" : "14:00",  "Description": null  }     and the final output looks like    [  {  "ID" : "100001",  "Date" : "2022-09-02",  "Start Time" : "08:00",  "End Time" : "14:00",  "Record" : "Record 2",  "Description" : "Invalid values for ID or Date"  },  {  "ID" : "100002",  "Date" : "2022-09-02",  "Start Time" : "08:00",  "End Time" : "14:00",  "Record" : "Record 3",  "Description" : "Invalid values for ID or Date"  }      ]    I want to do it using groovy script but I don't know anything about the groovy script. Can you please help if anyone has done it before.   
						
					
					... View more
				
			
			
			
			
			
			
			
			
			
		
		
			
				
						
							Labels:
						
						
		
			
	
					
			
		
	
	
	
	
				
		
	
	
- Labels:
 - 
						
							
		
			Apache NiFi