admin管理员组

文章数量:1353265

I am to create an address collection form for my work team. How do I make it so that when someone on my team submits their data it will create a new entry and if it there is an existing entry, then it will update the previous entry?

I like to make it so that the work "alias" box is used a reference to determine if there is an existing entry.

Currently, my formula to create new entries is:

Patch(
    'Shipping Form',
    Defaults('Shipping Form'),
    {
        'First Name': firstnameinput.Text,
        'Last Name':lastnameinput.Text,
        'Alias':aliasinput.Text,
        'Address Line 1':addressline1input.Text, 
        'Address Line 2':addressline2input.Text,
        'State/Province':stateinput.Text,
        'Zip/Postal Code':zipinput.Text,
        'City/Region':cityinput.Text, 
        'Permission to share to Reporting Manger if needed?':'Perminput', 
        'Country': CountryData, 
        'Contact Name': Contactnumberinput.Text, 
        'Comments:':commentinput.Text
    }
)
;ResetForm(Form2)

How do I add onto the formula for it to also check for existing entries based on "alias" and update if there is a duplicate "alias" value?

Thank you,

I am to create an address collection form for my work team. How do I make it so that when someone on my team submits their data it will create a new entry and if it there is an existing entry, then it will update the previous entry?

I like to make it so that the work "alias" box is used a reference to determine if there is an existing entry.

Currently, my formula to create new entries is:

Patch(
    'Shipping Form',
    Defaults('Shipping Form'),
    {
        'First Name': firstnameinput.Text,
        'Last Name':lastnameinput.Text,
        'Alias':aliasinput.Text,
        'Address Line 1':addressline1input.Text, 
        'Address Line 2':addressline2input.Text,
        'State/Province':stateinput.Text,
        'Zip/Postal Code':zipinput.Text,
        'City/Region':cityinput.Text, 
        'Permission to share to Reporting Manger if needed?':'Perminput', 
        'Country': CountryData, 
        'Contact Name': Contactnumberinput.Text, 
        'Comments:':commentinput.Text
    }
)
;ResetForm(Form2)

How do I add onto the formula for it to also check for existing entries based on "alias" and update if there is a duplicate "alias" value?

Thank you,

Share Improve this question edited Mar 31 at 20:40 carlosfigueira 87.4k14 gold badges136 silver badges174 bronze badges asked Mar 31 at 20:09 Wesley HWesley H 51 bronze badge New contributor Wesley H is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

The second argument to the Patch function is the record to be updated; if you use Defaults(...), then a new record is created. So you can use something like this to update a record if it exists, or create otherwise:

With(
    {
        recordToUpdate:
            Coalesce(
                LookUp('Shipping Form', Alias = aliasinput.Text),
                Defaults('Shipping Form')
            )
    },
    Patch(
        'Shipping Form',
        recordToUpdate,
        {
            'First Name': firstnameinput.Text,
            'Last Name':lastnameinput.Text,
            'Alias':aliasinput.Text,
            'Address Line 1':addressline1input.Text, 
            'Address Line 2':addressline2input.Text,
            'State/Province':stateinput.Text,
            'Zip/Postal Code':zipinput.Text,
            'City/Region':cityinput.Text, 
            'Permission to share to Reporting Manger if needed?':'Perminput', 
            'Country': CountryData, 
            'Contact Name': Contactnumberinput.Text, 
            'Comments:':commentinput.Text
        }
    )
)
;ResetForm(Form2)

本文标签: How do I update a duplicate entries in PowerappsStack Overflow