PowerApps - код влияет на производительность приложения из-за дублирования циклов If else - PullRequest
1 голос
/ 13 мая 2019

У меня есть фрагмент кода, который сохраняет элемент только при необходимости.

Вот код,

//identify the required organization and Dropdown value
    Set(requiredOrganization,Organization.Selected.OrganizationName.Text);
    Set(DropdownValue, Trim(Dropdown1.Selected.Value));
    If(DropdownValue = "Others", Set(segmentrationalrequired,"Others:" & TextInput3_1.Text),Set(segmentrationalrequired,DropdownValue));

//Identify the Audit Details - // Audit Trail Update
    If(TextInput2_48.Text = "", Set(AuditTrail,TextInput2_48.Text) , Set(AuditTrail, TextInput2_48.Text & Char(13)));
    Set(UpdatedAuditTrail, AuditTrail & "Allocated By " & User().FullName & " on " & Substitute(Text(Now()),":","-") & ". ");

//Update the Graph
        ClearCollect(CurrentYearAllocationsGraphFinal2, 
        {Category: Label11_17.Text, 'Upcoming Year':TextInput2_8.Text,'Current Year':TextInput2_32.Text},
        {Category: Label11_18.Text, 'Upcoming Year':TextInput2_9.Text,'Current Year':TextInput2_33.Text},
        {Category: Label11_19.Text, 'Upcoming Year':TextInput2_10.Text,'Current Year':TextInput2_34.Text},
        {Category: Label11_20.Text, 'Upcoming Year':TextInput2_11.Text,'Current Year':TextInput2_35.Text});

//Save the value in the One Drive file Table
        If(And(Label11_23.Text = "100", segmentrationalrequired <> "",segmentrationalrequired <> "Others:",DropdownValue<>Blank()), Patch(Table1,
        First(Filter(Table1, 'Organizational Code by Function Head' = requiredOrganization)),
        {'100 or Less': (Value(TextInput2_8.Text))/100}, 
        {'Premier (100 - 4,999)': (Value(TextInput2_9.Text))/100}, 
        {'NAO (>5,000)': (Value(TextInput2_10.Text))/100}, 
        {Association: (Value(TextInput2_11.Text))/100},
        {'Segment Rationale': segmentrationalrequired},
        {'Current Status':"Ready to be Sent for Approval"}, 
        {'Allocated By' : User().FullName},
        {'Segment Rationale File Details':TextInput2_37.Text}, 
        {'Allocated On': Now()}, 
        {'Audit Details': UpdatedAuditTrail}
        ),
        Notify("Allocations must total 100%. Please include your Allocation Methodology"));

//Refresh if Successful
        If(And(Label11_23.Text = "100", segmentrationalrequired <> "",segmentrationalrequired <> "Others:",DropdownValue<>Blank()),
        Refresh(Table1) & Refresh(Table4));

//Set default selected item of a gallery
Set(default_gallery_Market,First(Filter(Table1, 'Organizational Code by Function Head' = requiredOrganization)));

Есть ли лучший способ написать этот код, как он естьвлияющих на производительность.

Могу ли я остановить выполнение кода, если сохранение не удалось и дальше не идет ??

...