cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Hash Key

kylevarga
Deputy Chef I
Deputy Chef I

Has anyone had success using a dynamic hash key? Use case is I have a lookup table that has 2 columns that are just Keys and I have 2 objects (one from JIRA one from Salesforce) and I want to loop through each lookup table and do a comparison to determine if the values changed. pseudocode version:

 

sf = {'field1': '123'}
jira = {'field_1__c': '123' }
lookuptable = [{'jira': 'field1', 'sf': 'field_1__c' }]
for fieldLookup in lookuptable:
  if jira[fieldLookup['jira']] != sf[fieldLookup['sf']:
    isChanged=True

 My attempts using jiraFieldsPill[jiraLookupPill]  and jiraFieldsPill["jiraLookupPill"]  keep just giving me generic 'Recipe Error'

1 REPLY 1

Bhagya_pola
Deputy Chef III
Deputy Chef III

Hello @kylevarga ,
The error you're seeing is likely due to a key mismatch between your lookup table and the actual jira object.
In your example, you’ve defined the jira object like this:

jira = {'field_1__c': '123' }

But in your loop, you're doing:

jira[fieldLookup['jira']]

And your lookup table contains:

lookuptable = [{'jira': 'field1', 'sf': 'field_1__c' }]

So basically, your code is trying to access jira['field1'], but that key doesn’t exist in the JIRA object — it only has field_1__c That’s why you’re getting an error.
Also, just a quick note — field_1__c looks like a Salesforce custom field (since __c is usually used for those), so it probably belongs to Salesforce, not JIRA.
Hope I got your question right — let me know if I misunderstood anything!