Hello, I'm trying to find a way to perform addition and subtraction using functions.
Before, my name was 'Dylan Davis,' and I had a balance of '0' in the list.
When staff or teachers fill out the form and submit it, students can view the transaction history to see where teachers or staff have received deposits or withdrawn Dragon Tickets.
After submitted, the deposit or withdrawn should be updated to numbers for students and displayed as number on the screen, it is connected to the SharePoint list 'DHS Student Users'. Addition is indicated by a plus sign (+) for DESPOSIT, while subtraction is represented by a minus sign (-) for WITHDRAWN. Where's $45??
Last thing, regarding my transaction history: How can I look up if the User().Full name matches and display a list, which may contain more than one entry?
Hi @dylandavis09 ,
Ok, this is what I've done at my end, works ok at the moment but may need something better.
I've added a text input box to add values, called txtValue. I've also got a dropdown box called dpdChoice that has Deposit & Withdrawn as the two options. I've also added a user email & ID column for unique identifiers as more than one person could have the same name.
I have a button that, when clicked, will:
a) add a new transaction to the Transactions list
b) update the D-Tickets value for the relevant user
So adding the transaction:
// Determine whether value will be a positive or negative amount
With(
{
tvValue: If(
dpdChoice.Selected.Value = "Deposit",
Value(txtValue.Text),
Value(txtValue.Text) * -1
)
},
// Create new entry in Transactions list
Patch(
'Transaction History',
Defaults('Transaction History'),
{
Title: "Dylan Davis",
Email: "dylan.davis@email.com",
UserID: 1,
Deposit: Value(tvValue),
'Deposit Type': dpdChoice.Selected.Value
}
)
);
Then, updating the D-Tickets value for the relevant user. I'm using the List ID of the person for a one-to-one match:
// Sum all of users transactions
With(
{
tvSum: Sum(
Filter(
'Transaction History',
UserID = 1
),
Deposit
)
},
// Update users D-Tickets total
Patch(
'DHS Student Users',
{ID: 1},
{'D-Tickets': tvSum}
)
)
I've tested at my end and works ok, though may need a better solution that avoids delegation:
------------------------------------------------------------------------------------------------------------------------------
If I've answered your question, please mark your post as Solved. You can accept more than one post as a solution.
If my response was a good one, please give it a Thumbs Up!
Visit my blog: https://platformsofpower.net
@cdwhite, thank you for understanding what I want to achieve. Let me explain. You are correct: when a new line is added to the PBiS Transaction History, we need to sum up all transactions for one student and then send the updated totals to the DHS Student Users. For example, if a teacher makes a $45 deposit and later another $100 deposit, there should be an overall total that needs to be updated in the list based on the matching full name.
How it makes if deposit (sum), and withdrawn (subtract).
PBiS Transaction History:
Dylan Davis $45 Deposit
Dylan Davis $100 Deposit
Need to update the DHS Student Users:
Dylan Davis $145
Hi @dylandavis09 ,
If I understand correctly, when the line is added to the PBiS Transaction History list, it needs to update the entry for the relevant student in the DHS Students Users list? If so, would that mean you'll need to sum up ALL transactions for one student? For example, Dylan could have multiple transactions at $45, so would there need to be an overall total that needs updating?
In terms of your query around User().FullName - you're correct, this won't be unique as multiple people could have the same name. In Active Directory & Exchange, this is bypassed by the users email address, as this will ALWAYS be unique to the individual user. You can access this with User().Email, though I'd always recommend the Office 365 Users approach personally.
------------------------------------------------------------------------------------------------------------------------------
If I've answered your question, please mark your post as Solved. You can accept more than one post as a solution.
If my response was a good one, please give it a Thumbs Up!
Visit my blog: https://platformsofpower.net
WarrenBelz
146,645
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional