web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

avoid repeated code

(0) ShareShare
ReportReport
Posted on by 150
Hi,

Isn't there a way to not repeat code for table1 and 2? the fields are the same, it's just that i want to fill the contract based on type.
There is also more common fields, but just wrote some for the sake of the question

if there is a way to somehow say
common = salesTable or projTable
then directly poss common and repeat code once..is the only way to create a map?
    private void method1(Table1 _table1, Table2 _table2, ContractClass1 _contractClass1)
    {
        UnknownNoYes enumValue;

        if (_table2 && _table1.Type == Enum1::A)
        {
            _contractClass1.parmPurchOrderFormNum(_table2.PurchOrderFormNum);
            _contractClass1.parmField1(str2Enum(enumValue, enum2Value(_table2.Field1)));
            _contractClass1.parmField2(str2Enum(enumValue, enum2Value(_table2.Field2)));
            _contractClass1.parmField3(str2Enum(enumValue, enum2Value(_table2.Field3)));
            _contractClass1.parmMainContactName(_table2.Name);
            _contractClass1.parmMainContactPhone(_table2.Phone);
            _contractClass1.parmMainContactEmail(_table2.Email);
            
  
        }
        else if (_table1.Type == Enum1::B)
        {
            _contractClass1.parmPurchOrderFormNum(_table1.PurchOrderFormNum);
            _contractClass1.parmField1(str2Enum(enumValue, enum2Value(_table1.Field1)));
            _contractClass1.parmField2(str2Enum(enumValue, enum2Value(_table1.Field2)));
            _contractClass1.parmField3(str2Enum(enumValue, enum2Value(_table1.Field3)));
            _contractClass1.parmName(_table1.Name);
            _contractClass1.parmPhone(_table1.Phone);
            _contractClass1.parmEmail(_table1.Email);
        }
    }
 
Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 555 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 364

#3
Diego Mancassola Profile Picture

Diego Mancassola 259

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans