cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EdevaldoJeronim
Resolver I
Resolver I

The type of this argument does not match the expected type 'record'

I'm trying to execute the code below to update a list in SP, but are appearing the error below in the field "IdPlanta".

This field in SP is a Lookup format so i need to choice to another list.

the error: "The type of this argument does not match the expected type 'record'"

 

ForAll(TblMenuUser_Excel;
If(IsBlank(
LookUp(TblMenuUser;IdUser = TblMenuUser_Excel[@CHV_COD_USR]));
Patch(TblMenuUser;
Defaults(TblMenuUser);
{
IdUser:TblMenuUser_Excel[@CHV_COD_USR];
IdPlanta:TblMenuUser_Excel[@ID_Planta]};
UserNome:TblMenuUser_Excel[@TXT_NOME];
UserApelido:TblMenuUser_Excel[@TXT_APELIDO];
DtInclusao:TblMenuUser_Excel[@DTA_INCLUSAO];
DtAtualizacao:TblMenuUser_Excel[@DTA_ATUALIZACAO];
UserEmail:TblMenuUser_Excel[@TXT_EMAIL];
UserLogado:TblMenuUser_Excel[@UserLOGADO];
UserAtivo:TblMenuUser_Excel[@UserATIVO]
}
)
)
)

 

1 ACCEPTED SOLUTION

Accepted Solutions

thank  you @RandyHayes ,

Now it's working fine

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@EdevaldoJeronim 

What type of column in your SharePoint list is IdPlanta?  If it is a lookup (my guess) then you need to provide a record to that column.

 

If it is a lookup column, then you will need to supply a record with an Id and a Value.

 

Also a couple of critiques on the Formula you have. You can change it to the following as you are wasting the output of your ForAll.

Collect(TblMenuUser;
  Filter(
    ForAll(TblMenuUser_Excel;
       If(!LookUp(TblMenuUser; IdUser = CHV_COD_USR, true);
          {
          IdUser: CHV_COD_USR;
          IdPlanta: <I'll hold off on this one until you respond with your column type>;
          UserNome: TXT_NOME;
          UserApelido: TXT_APELIDO;
          DtInclusao: DTA_INCLUSAO;
          DtAtualizacao: DTA_ATUALIZACAO;
          UserEmail: TXT_EMAIL;
          UserLogado: UserLOGADO;
          UserAtivo: UserATIVO
         }
       )
    );
    !IsEmpty(ThisRecord)
  )
)

 The above will do as you are trying to do without the need and account for the new and updates of records as well.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you for the answer @RandyHayes

The sharepoint collum type is:

IdUser: Txt field

IdPlanta : Lookup field

UserLogado: Option field (S or N)

UserAtivo: Option field (S or N)

 

Thank you in advance

 

RandyHayes
Super User
Super User

@EdevaldoJeronim 

As expected...and with a little bonus for UserLogado and UserAtivo (as those will cause you issues as well).

So for the IdPlanta, you need to provide a record.  You need to have the Id and the Title (usually) of the record from the Lookup list you have defined.

Also, for the two options, you will need to provide them as a record also.

 

So, based on what I showed before, this is where you need to head toward.  You still need to get the Id and Title of the lookup record for this to work and I don't have enough details from you to provide that, but I will give you the structure:

Collect(TblMenuUser;
  Filter(
    ForAll(TblMenuUser_Excel;
       If(!LookUp(TblMenuUser; IdUser = CHV_COD_USR, true);
          {
          IdUser: CHV_COD_USR;
          IdPlanta: {Id: theIDofTheLookupRecord; Value: theTitleColumnOfTheLookupRecord};
          UserNome: TXT_NOME;
          UserApelido: TXT_APELIDO;
          DtInclusao: DTA_INCLUSAO;
          DtAtualizacao: DTA_ATUALIZACAO;
          UserEmail: TXT_EMAIL;
          UserLogado: {Value: UserLOGADO};
          UserAtivo: {Value: UserATIVO}
         }
       )
    );
    !IsEmpty(ThisRecord)
  )
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

thank  you @RandyHayes ,

Now it's working fine

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 (1,921)