Hi,
I have a create customer service that accepts some parameters related to the customer in addition to a list of contact persons to be created for the customer.
I want to create the parties for the contact person first -- where as you can see i call "createCustomerContactPersonParty" method and insert parties based on the list of contact persons coming to the service input -- where i save all parties created in a list.
Now i want to use these parties created to create the actual contact person where i pass the party created to contactPersonEntity.ContactPersonPartyNumber
The thing is let's say i have those contacts as an input
Name: contactPerson1
Name: contactPerson2
and then i created 2 party records using dirPartyBaseEntity by filling the name and saving the party created for each one in a list
now how can i pass the parties i created to the correct contact person, the two while loops with move next are not helping me.. because i want the first party created to be passed to the first contact(the one that matches the name,then when i loop to the next contact, i want to pass the 2nd party created etc...not sure how to do it
class createCustomerService
{
public CustomerResContract createCustomerDetails(CustomerReqContract _custDetails) //custDetails has firstName and Lastname of the contact person
{
PartyNumber customerContactPersonPartyNumber;
List contactPersons = new List(Types::Class);
ListEnumerator listContactPersonEnum;
List customerContactPersonPartyNumbers;
ListEnumerator listCustomerContactPersonPartyNumbersEnum;
contactPersons = _custDetails.ContactPerson();
if(contactPersons)
{
listContactPersonEnum = contactPersons.getEnumerator();
customerContactPersonPartyNumbers = new List(Types::String);
if(listContactPersonEnum)
{
while (listContactPersonEnum.moveNext())
{
contactPerson = listContactPersonEnum.current();
ttsbegin;
customerContactPersonPartyNumbers.addEnd(this.createCustomerContactPersonParty(contactPerson));
ttscommit;
}
}
}
// logic
ttsbegin;
this.createcustomer();
//logic
listContactPersonEnum.reset();
if(listContactPersonEnum)
{
while (listContactPersonEnum.moveNext())
{
contactPerson = listContactPersonEnum.current();
if(customerContactPersonPartyNumbers)
{
listCustomerContactPersonPartyNumbersEnum = customerContactPersonPartyNumbers.getEnumerator();
if(listCustomerContactPersonPartyNumbersEnum)
{
while (listCustomerContactPersonPartyNumbersEnum.moveNext())
{
customerContactPersonPartyNumber = listCustomerContactPersonPartyNumbersEnum.current();
ContactPersonCreator personCreator= new ContactPersonCreator();
personCreator.createContactPerson(contactPerson, custTable, customerContactPersonPartyNumber);
break;
}
}
}
}
}
}
public PartyNumber createCustomerContactPersonParty(ContactPersonContract _contactPerson)
{
DirPartyBaseEntity dirPartyBaseEntity;
dirPartyBaseEntity.PartyType = enum2Str(DirPartyType::Person);
dirPartyBaseEntity.Name = _contactPerson.PersonDetails().FirstName();
dirPartyBaseEntity.insert();
return dirPartyBaseEntity.PartyNumber;
}
}