Not sure if I am asking this correctly, but here is what we are trying to do. We want to create a subject line that will pull through each appointment's patient name and append it to the end of the subject line for each iteration. Not very far on this one so any help is appreciated.
Final outcome: If 1 appointment We are looking forward to Tom's appointment!
If more than 1... We are looking forward to Tom's and Jane's appointment!
If more than 2... We are looking forward to Tom's, Jane's, and Cindy's appointment!
Updated snippet
var @xml, @SubjectLine, @GroupRecords, @row, @FirstName, @FirstNameGroup, @FirstNameLoop, @FirstNameFinal, @tempset
set @xml = XML_Feed
Set @GroupRecords = BuildRowsetFromXml(@xml, "//Record", 1)
Set @rowcount = Rowcount(@GroupRecords)
Set @FirstNameLoop = ""
If not empty(@GroupRecords) then
Set @tempset = @rowcount
Set @FirstNameFinal = ProperCase(Field(1,"FirstName_att"))
If @tempset != 1 Then
for @i = 1 to @rowcount do
Set @row = Row(@GroupRecords,@i)
Set @FirstName = ProperCase(Field(@row,"FirstName_att"))
IF @i == @tempset THEN
SET @FirstNameFinal = CONCAT(@FirstNameLoop," and ",@FirstName,"'s ")
ELSE
SET @FirstNameGroup = CONCAT(@FirstNameLoop," , ", @FirstName)
ENDIF
SET @FirstNameLoop = @FirstNameGroup
Next @i
ENDIF
ENDIF
SET @SubjectLine = Concat("We are looking forward to ",@FirstNameFinal,"'s appointment!")
Sample XML: Root Record AppointmentConfirmedYN="N" AppointmentDateTime="Dec 21 2015 1:00PM" AppointmentId="29986792" AppointmentSubTypeCode="" AppointmentTypeCode="1" CellPhone="18036165144" ClinicId="8" EmailAddress="[email protected]" FamilyId="2352212" FirstName="Kanika" HOHID="6034997" InsuranceStatusCode="2" LastName="White" MessageId="531111" PatientId="6034997" PayerTypeCode="1" RescheduleYN="N"