cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BOTViking
New Member

Access to custom element in a gallery using ForAll

Hello,

 

I have an application with a button and a gallery.

 

The Gallery retrieve data from a Sharepoint List of supplies requests. I added a text entry named "Number_Data" for each row in order to iterate on the quantity to provide.

 

With the button, I iterate on my Gallery elements and patch if necessary the Sharepoint List.

 

Here is the OnSelect property of the button :

 

ForAll
(
  Galery_1.AllItems;
  If
  (
    Value(Number_Data.Text) > 0;
    Collect
    (
      Tmp;
      {
        id_tmp:ID;
        id_stock_tmp:id_stock;
        qty:Value(Number_Data.Text)
      }
    )
  )
);;
ForAll
(
  Tmp;
  Patch
  (
    'Supplies - Stock';
    LookUp
    (
      'Supplies - Stock';
      ID = id_stock_tmp
    );
    {
      ActualStock:
      LookUp
      (
        'Supplies - Stock';
        ID = id_stock_tmp;
        ActualStock
      ) - Tmp[@qty]
    }
  )
);;

Clear(Tmp)

 

The problem is that if I have 3 lines and that I filled the 3 text entries, it will take the first line text entry for all the lines...

How can I fix that so it's taking the good text entry value ?

 

Thanks for your answers

1 ACCEPTED SOLUTION

Accepted Solutions

I can access to all the columns of my Sharepoint List, and also to the text input which is not extracting data from the Sharepoint List.

However, I can access to the Text property by doing :

qty: Value(Number_Data.Text)

 

And it seems to works properly now. Code :

 

ForAll

(

   Galerie1.AllItems;

    If

    (

        Value(Number_Data.Text) > 0;

        Collect

        (

            Tmp;

            {

                id_tmp:ID;

                id_stock_tmp:id_stock;

                qte:Value(Number_Data.Text)

            }

        )

    )

);;

ForAll

(

    Tmp;

    Patch

    (

        'Supplies - Stock';

        LookUp

        (

            'Supplies - Stock';

            ID = id_stock_tmp

        );

        {

            ActualStock:

            LookUp

            (

                'Supplies - Stock';

                ID = id_stock_tmp;

                ActualStock

            ) - qte

        }

    )

)

View solution in original post

4 REPLIES 4
iAm_ManCat
Super User
Super User

Hi,

 

Where you have:

qty:Value(Number_Data.Text)

 

You can instead use:

qty:Value(Galery_1.AllItems.Number_Data.Text)

 

Please give that a try and let me know if that helps solve your issue,

 

Thanks,

Sancho

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


I have an error with this, looks like I can't acces to Number_Data properties, Text isn't recognized.

If you type

qty:Value(Galery_1.AllItems.

 

What options does it give you from the intellisense - there should be an object name or a column name from the data source that is similar to Number_Data

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


I can access to all the columns of my Sharepoint List, and also to the text input which is not extracting data from the Sharepoint List.

However, I can access to the Text property by doing :

qty: Value(Number_Data.Text)

 

And it seems to works properly now. Code :

 

ForAll

(

   Galerie1.AllItems;

    If

    (

        Value(Number_Data.Text) > 0;

        Collect

        (

            Tmp;

            {

                id_tmp:ID;

                id_stock_tmp:id_stock;

                qte:Value(Number_Data.Text)

            }

        )

    )

);;

ForAll

(

    Tmp;

    Patch

    (

        'Supplies - Stock';

        LookUp

        (

            'Supplies - Stock';

            ID = id_stock_tmp

        );

        {

            ActualStock:

            LookUp

            (

                'Supplies - Stock';

                ID = id_stock_tmp;

                ActualStock

            ) - qte

        }

    )

)

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,595)