The primary half is to create a brand new undertaking, which requires as one of many fields the title of the account on the undertaking. When the undertaking is saved, the first contact on the account document is robotically added as a Undertaking Member. The Picture under reveals the creation of the brand new undertaking.

When the document is saved, a Cloud Circulation is being known as that retrieves the Main Contact on from the account document, and creates the First Undertaking Member on the Undertaking. It additionally marks the member as Main, in order that it can’t be deleted from the App. The picture under accommodates the steps within the Cloud Circulation.

Canvas App - Membership Management - New Project - Cloud Flow

After the circulate is executed, we will see the undertaking member that was added inside the undertaking document, as proven under.

Canvas App - Membership Management - New Project - After Cloud Flow

Subsequent, let’s go forward and take a look at the Canvas App. After we load the Canvas App, we’ve got the flexibility to pick the undertaking that we wish, after which as soon as the undertaking is chosen, we’ll see the Undertaking Members within the gallery (as proven under). You’ll discover that there’s a single member that’s seen, as it is a new undertaking that was created, and the default member was added to the undertaking.

Canvas App - Membership Management - Canvas Initial View

You’ll discover the + button above the gallery. Clicking on the Plus button will enable us so as to add a brand new Undertaking Member. The motion will present a brand new part on the shape which can request a Contact, Date Added and Proportion, as proven under. The Contact discipline is filtered to solely present members that haven’t but been added to the gallery.

Canvas App - Membership Management - Canvas Add New Member

As soon as the member is added, I can see the 2 members in my gallery. I additionally see that the Save button is disabled, as a result of the overall membership share isn’t equal to 100%. I’ll add yet another member for the aim of the demo. I now see that I’ve three members with a complete membership share of 160%

Canvas App - Membership Management - Canvas Multiple Members - Unable to Save

To ensure that me to Save this document, I’ll have change the odds in order that they’re equal to 100%. Let’s go forward and try this, after which Save the document to see the outcomes.

Canvas App - Membership Management - Canvas Multiple Members - 100%

Canvas App - Membership Management - Canvas Multiple Members - After Save

Now, let’s return to the canvas app, and take away considered one of these members. You’ll discover that Paul Cannon, which is the Main Member doesn’t have a take away icon, as a result of that’s the main member. All different members, we will delete. Let’s go forward and delete Nancy Anderson, which has a 30% membership. The member is highlighted as eliminated. As a way to save the adjustments once more, we’ve got to replace the odds to match 100%, after which save the adjustments. The picture under reveals the document to be eliminated and the up to date percentages.

Canvas App - Membership Management - Canvas Multiple Members - Remove

Now let’s go forward and save the document, and take a look at the ends in the Mannequin-Pushed app. You’ll discover that I nonetheless see the three Undertaking Members, however that’s as a result of I’m displaying each Lively and Inactive Customers. The member that was faraway from the group is displaying a date worth within the Member Eliminated on, which permits me to maintain observe of the members added and eliminated, and a historical past of such.

Canvas App - Membership Management - Canvas Multiple Members - After Save (Member Removed)

Subsequent, let’s go forward and take a look at the implementation. First, when the shape hundreds, we choose a undertaking and click on on the Go button. The OnSelect methodology of the Go button accommodates logic to load the tasks into a set, and cargo contacts into a set eradicating the contacts which are already added to the undertaking.

Set(SelectedProject, cmbProject.Chosen.Tasks); 

// Add Undertaking Members to the Gallery
Clear(ProjectMembers);
ForAll(
    Filter('Undertaking Members', Undertaking.Tasks = SelectedProject, Standing="Standing (Undertaking Members)".Lively),
Accumulate(ProjectMembers,
{
    ProjectMemberId: 'Undertaking Member',
    ProjectId: Undertaking.Tasks,
    ContactId: Contact.Contact,
    Identify: Contact.'Full Identify',
    DateAdded: 'Member Added On',
    Proportion: Proportion,
    IsPrimary: 'Is Main',
    IsDeleted: false
})
);

// Add All Contacts to the Assortment to permit including of latest contacts
Clear(AvailableContacts);
ForAll(Filter(Contacts, Function="Function (Contacts) Choice Maker"),
Accumulate(AvailableContacts,
{
    ContactId: Contact,
    FullName: ''Full Identify',
    IsAvailable: true
})
);

// Mark the Contacts which are already within the Undertaking Members Gallery as not obtainable
// in order that they don't seem within the Contacts Combo Field
ForAll(ProjectMembers,
    Patch(AvailableContacts,
        First(Filter(AvailableContacts, FullName = Identify)),
        { IsAvailable: false })
        );

Set(hasError, false);

The plus button, solely units an Motion Sort worth to Add, which in flip shows all the listing of controls which are seen to permit addition of a brand new document. As soon as clicked I can see the Add Undertaking Member, Contact, Date Added, Proportion fields, and the Settle for and Cancel icons.

The Contact Combo Field, has a Filter to solely present Obtainable Contacts, utilizing the next line:
Filter(AvailableContacts, IsAvailable = true)

Clicking on the examine button (Settle for), will add a brand new Undertaking Staff Member into the gathering, and take away that member from the listing of accessible Contacts.

If(IsBlank(cmbContact.Chosen.FullName),
   Set(hasError, true), 
    Accumulate(ProjectMembers,
    {
        ProjectId: GUID(SelectedProject),
        ContactId: cmbContact.Chosen.ContactId,
        Identify: cmbContact.Chosen.FullName,
        Proportion: sliderPercentage.Worth,
        DateAdded: dtpDateAdded.SelectedDate,
        IsPrimary: 'Is Main (Undertaking Members)'.No,
        IsDeleted: false
    });
    Patch(AvailableContacts,
        First(Filter(AvailableContacts, ContactId = cmbContact.Chosen.ContactId)),
        { IsAvailable: false }
        );
    Set(hasError, false)
);

Reset(cmbContact);
Set(ActionType, "");

Lastly, for the Save motion, I loop via all of the Undertaking Staff Members, and both create a brand new member (primarily based on the Undertaking Member Id being clean), or replace an current document. The replace patch can both replace the proportion of the undertaking or deactivate the undertaking.

ForAll(ProjectMembers,
    If (IsBlank(ProjectMemberId),
        // Create New File
        Patch('Undertaking Members', Defaults('Undertaking Members'),
        {
            Undertaking: LookUp(Tasks, Tasks = ProjectId),
            Contact: LookUp(Contacts, Contact = ContactId),
            'Is Main': 'Is Main (Undertaking Members)'.No,
            'Member Added On': DateAdded,
            Proportion: Proportion
        }),
        // Replace Present File
        Patch('Undertaking Members', LookUp('Undertaking Members', 'Undertaking Member' = ProjectMemberId),
        {
            Proportion: Proportion,
            'Member Eliminated On': If (IsDeleted, Right now(), ""),
            Standing: If (IsDeleted, 'Standing (Undertaking Members)'.Inactive, 'Standing (Undertaking Members)'.Lively),
            'Standing Motive': If (IsDeleted, 'Standing Motive (Undertaking Members)'.Inactive, 'Standing Motive (Undertaking Members)'.Lively)
        })
    );
);

Choose(Button2);

Under additionally, you will discover a video of this weblog and I’ll add the supply code to my github repository as quickly as I can.

LEAVE A REPLY

Please enter your comment!
Please enter your name here