Iterating to return contacts .ReferenceNumber value

Discussions related to writing and managing custom business rules.

Moderator: Phil Barton

Post Reply
DanChapin
Posts: 16
Joined: Thu Sep 24, 2015 10:40 am

Iterating to return contacts .ReferenceNumber value

Post by DanChapin » Tue Oct 11, 2016 12:15 pm

Hi Everyone,

I am working on a regular formula and nobody seems to be able to help me. I am simply trying to get the .Name and .ReferenceNumber from the 1st contact in the file marked as the source of business. I am using the following:

Iterate {{Order.Contacts}} from 1 to #{{Order.Contacts}}
If(@.IsMarketingSource) Then
value = @.Name + " Is the marketing Source. "
value = value + "Reference #: " + {{Order.SettlementAgents[1].ReferenceNumber}}
endif
loop


Pretty simple code, except that the only way I can return the .ReferenceNumber is by actually naming the SettlementAgents[1] contact type. I do not know who the contact is or if it is [1] or [2] etc…. so I cannot figure out how to get at the .ReferenceNumber field which is not available the same as .Name is above. I thought that perhaps I needed another nested Iterate that looped the @.ContactType item but that doesn’t get me to the referencenumber either. Any Ideas?

Thanks
Dan

DanChapin
Posts: 16
Joined: Thu Sep 24, 2015 10:40 am

Re: Iterating to return contacts .ReferenceNumber value

Post by DanChapin » Wed Oct 12, 2016 9:23 am

FOLLOW UP:

I found yesterday that other than by using a Business Rule, there is no way to get the value of a contacts ReferenceNumber field within an iterate by using the short @.ReferenceNumber. In a formula, it can only be accessed by using {{Order.Attorneys[1].ReferenceNumber}}. So with that information, I used the fields available (@.ContactTypeDescription, to be specific), with the knowledge that the customer’s client would be limited to one of a few contacts, together with a case statement to achieve my goal. Here is my working code.

// Email Subject Line
// Formatted as "Our Order #XXXXXX, Your Reference #123A45"
// Find 1st Marketing Source. If entered, grab the Reference Number from the contact
value = ""
value = value + "Our Order #" + {{Order.Number}}
Iterate {{Order.Contacts}} from 1 to #{{Order.Contacts}}
If(@.IsMarketingSource) Then
Case ( @.ContactTypeDescription )
CaseOf 'Attorney':
If( Not IsEmpty( {{Order.Attorneys[1].ReferenceNumber}} )) Then
value = value + ", Your Reference #" + {{Order.Attorneys[1].ReferenceNumber}}
EndIf
CaseOf 'Title Company':
If( Not IsEmpty( {{Order.TitleCompanies[1].ReferenceNumber}} )) Then
value = value + ", Your Reference #" + {{Order.TitleCompanies[1].ReferenceNumber}}
EndIf
CaseOf 'Escrow Company':
If( Not IsEmpty( {{Order.EscrowCompanies[1].ReferenceNumber}} )) Then
value = value + ", Your Reference #" + {{Order.EscrowCompanies[1].ReferenceNumber}}
EndIf
CaseOf 'Other (Trustee)':
If( Not IsEmpty( {{Order.Others[2].ReferenceNumber}} )) Then
value = value + ", Your Reference #" + {{Order.Others[2].ReferenceNumber}}
EndIf
CaseOf 'Other (Client)':
If( Not IsEmpty( {{Order.Others[3].ReferenceNumber}} )) Then
value = value + ", Your Reference #" + {{Order.Others[3].ReferenceNumber}}
EndIf
CaseOf 'Settlement Agent':
If( Not IsEmpty( {{Order.SettlementAgents[1].ReferenceNumber}} )) Then
value = value + ", Your Reference #" + {{Order.SettlementAgents[1].ReferenceNumber}}
EndIf
AllOthers:
value = value + ""
EndCase
Break
EndIf
loop

Post Reply