cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
snookinn77
Level: Powered On

Assigning ticket to user based on help type selection. Not working properly!?

Brief: This is an IT ticket app that started as one of the templates and I have customized it a bit. I have a "create ticket screen" where users can select a type of help they require (i.e. software, hardware, furniture), provide a description, etc. I have been trying to set up a function to assign the tickets to one of 5 people based on the user's selection of help type. No matter which help type I select, it always defaults to the first name. (everything on the data repository side is correct). Can anyone see something wrong here? 

 

Switch(Dropdown5.Selected.Value, "General Computer" || "Monitor/Keyboard/Mouse" || "Printer" || "Furniture" || "Office 365 Programs" || "Other",SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description: Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Bill",AccountName: Dropdown5.Selected.Value})}), "Sage" || "Salesforce",SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description: Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Adam",AccountName: Dropdown5.Selected.Value})}), "FileMaker",SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description: Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Liz",AccountName: Dropdown5.Selected.Value})}), "Cell Phone",SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Kelsea",AccountName:Dropdown5.Selected.Value})}))

 

UPDATE: I'm not sure if I need to use If or Switch or something totally different. I would like this to update the ticket being created and not affect any other ticket

2 REPLIES 2
Community Support Team
Community Support Team

Re: Assigning ticket to user based on help type selection. Not working properly!?

Hi @snookinn77,

 

So the Logic of the code is:

Take use of switch function, then use Submitform to create the record, and Patch to update the record created by the Submitform function?

Besides, could you please explain a bit for the sentence:

"No matter which help type I select, it always defaults to the first name. "

It would be more helpful if you could share a screenshot of the problematic form control.

From my understanding, the formula here is too complated.

If here only the Assigned to field is bound with the selected value, we could write the switch directly with the update property of the Assigned to DataCard.

Formula should be:

 

 

Switch(Dropdown5.Selected.Value, 
     "General Computer","Bill", 
"Monitor/Keyboard/Mouse","Bill",
"Printer", "Bill",
"Furniture","Bill",
"Office 365 Programs", "Bill",
"Other", "Bill", "Sage", "Adam" ,
"Salesforce", "Adam", "FileMaker","Liz", "Cell Phone","Kelsea")

the || operator is not available to use under the switch function, you should match each possible value to a proper record t omake the switch work.

Check the following article for more information about form control and DataCard:

Understand data forms in Microsoft PowerApps

Understand data cards

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
snookinn77
Level: Powered On

Re: Assigning ticket to user based on help type selection. Not working properly!?

 So I made these changes. I removed the || and let all of these stand alone. 

Switch(Dropdown5.Selected.Value, "General Computer",SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Bill",AccountName:Dropdown5.Selected.Value})}),
 "Monitor/Keyboard/Mouse", SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Bill", AccountName:Dropdown5.Selected.Value})}),
 "Printer", SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Bill",AccountName:Dropdown5.Selected.Value})}),
 "Furniture", SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Bill",AccountName:Dropdown5.Selected.Value})}),
 "Office 365 Programs", SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Bill",AccountName:Dropdown5.Selected.Value})}),
 "Other",SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Bill",AccountName:Dropdown5.Selected.Value})}),
 "Sage", SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Adam",AccountName:Dropdown5.Selected.Value})}),
 "Salesforce", SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Adam",AccountName:Dropdown5.Selected.Value})}),
 "FileMaker",SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Liz",AccountName:Dropdown5.Selected.Value})}),
 "Cell Phone", SubmitForm(NewTicketForm);UpdateContext({New:Patch(Tickets,LookUp(Tickets,ID=Text(Max(Tickets,ID))),{Subject:Subject.Text,Description:Description.Text,Image:AddMediaButton1.Media,AssignedTo:"Kelsea",AccountName:Dropdown5.Selected.Value})}))

 

Now when I create a new ticket, the ticket is assigned to the correct person. But now I have another issue. The ticket is assigned to the right person (ie. Furniture > Bill) but the actual record changes to the default of "General Computer".

 

The below example theoretically shouldn't be possible. In my code, when the function patches the record, is it pulling from what was selected before the submission or after once the form has reset?

 

Screen Shot 2017-09-07 at 1.29.28 PM.png

 

Thanks in advance and apologies if this is not clear enough.

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,035)