Hello everybody!!
I have an issue that is driving me crazy...
I need to populate a word in power automate... https://powerusers.microsoft.com/t5/Building-Flows/Populating-word-from-2-different-Apply-to-Each/m-p/1968417 this is my first post related to power automate.
To put it all into a comprehensible context. I need to populate a report (I have premium connector for word populating templates) and I am trying to add some signatures. I have worked uploading images before and I have many reports that are working perfectly.. but this one is driving me insane.
What I did first (my original problem) was getting my flow triggered from PowerApps and it sent a json collection to power automate with the signatures (name: colFirmas, and they are so many!!).
Let me explain.

Here are my 3 signatures per document. I need to get one document per count (each chemical per warehouse), that would make at least 50 documents, each with 3 signatures, so, those signatures change in every document. (a lot of signatures).
Since I haven't got any help with it, I have been looking for a workaround, and I thought I should try making only one collection directly from PowerApps, instead of trying to match a collection and SP List that I couldn't get to work.
So, I went back to my App and changed some formulas. I must add that my collection must work offline, so everything is built around collections.
To begin with, my original main database is imported as a collection (colBaseSP), now I have added 9 columns with the info I need for the signatures and that are not part of my SP List and they must not be uploaded to the SP list, only to my power automate (this wasn't in my original design... it was just collecting my SP List, no columns added)
ClearCollect(
colBaseSP;
AddColumns(Filter(
'Inventario Quimicos parte 1';
Dd_ZonaInventario.SelectedText.Value = 'Nombre Inventario'.Value
);"Base Firma Operador";"";"Nombre Foto Operador";"";"Firmante Operador";"";"Base Firma Encargado";"";"Nombre Foto Encargado";"";"Firmante Encargado";"";"Base Firma Jefe";"";"Nombre Foto Jefe";"";"Firmante Jefe";"")
So, this is my main collection.
When a signature is created, this happens
Set(varNombreFirma;
If(IsBlankOrError(LookUp(colNomina; Radio1.Selected.Value=Rol).Nombre);TextInput3.Text;LookUp(colNomina; Radio1.Selected.Value=Rol).Nombre) & "-" &varPlanta & "-" & VarQuimico
)
;;
Collect(colFirmas;
{
DisplayName: varNombreFirma & ".jpg";
ID: 1+Last(colFirmas).ID;
Apress: Pen_Firmas.Image;
Timestamp: Now();
Planta: varPlanta;
Firmante: If(IsBlankOrError(LookUp(colNomina; Radio1.Selected.Value=Rol).Nombre);TextInput3.Text;LookUp(colNomina; Radio1.Selected.Value=Rol).Nombre);
Tipo: "Conteo";
Quimico: VarQuimico;
'Codigo Quimico':LookUp(colBaseSP;VarQuimico='NOMBRE MATERIAL').'CÓDIGO MATERIAL';
Cargo: If(IsBlankOrError(LookUp(colNomina; Radio1.Selected.Value=Rol).Rol);"Operador Planta";LookUp(colNomina; Radio1.Selected.Value=Rol).Rol)
} );;Collect(colFirmaRapida;
{
DisplayName: varNombreFirma & ".jpg";
ID: 1+Last(colFirmas).ID;
Apress: Pen_Firmas.Image;
Timestamp: Now();
Planta: varPlanta;
Firmante: If(IsBlankOrError(LookUp(colNomina; Radio1.Selected.Value=Rol).Nombre);TextInput3.Text;LookUp(colNomina; Radio1.Selected.Value=Rol).Nombre);
Tipo: "Conteo";
Quimico: VarQuimico;
Cargo: If(IsBlankOrError(LookUp(colNomina; Radio1.Selected.Value=Rol).Rol);"Operador Planta";LookUp(colNomina; Radio1.Selected.Value=Rol).Rol);
'Codigo Quimico':LookUp(colBaseSP;VarQuimico='NOMBRE MATERIAL').'CÓDIGO MATERIAL'
} )
;;
Set(varCargo;If(IsBlankOrError(LookUp(colNomina; Radio1.Selected.Value=Rol).Rol);"Operador Planta";LookUp(colNomina; Radio1.Selected.Value=Rol).Rol));;Set(varFirmante;If(IsBlankOrError(LookUp(colNomina; Radio1.Selected.Value=Rol).Nombre);TextInput3.Text;LookUp(colNomina; Radio1.Selected.Value=Rol).Nombre));;Set(varArchivoFoto;varNombreFirma & ".jpg");;Set(varApressTemporal;Pen_Firmas.Image);;
If(varCargo="Operador Planta";
Patch(colBaseSP; LookUp(colBaseSP;PLANTA=varPlanta && 'NOMBRE MATERIAL'=VarQuimico);{'Nombre Foto Operador': varArchivoFoto;'Firmante Operador':varFirmante;'Base Firma Operador':varApressTemporal});If(varCargo="Encargado Bodega";Patch(colBaseSP; LookUp(colBaseSP;PLANTA=varPlanta && 'NOMBRE MATERIAL'=VarQuimico);{'Nombre Foto Encargado':varArchivoFoto;'Firmante Encargado':varFirmante;'Base Firma Encargado':varApressTemporal});Patch(colBaseSP; LookUp(colBaseSP;PLANTA=varPlanta && 'NOMBRE MATERIAL'=VarQuimico);{'Nombre Foto Jefe':varArchivoFoto;'Firmante Jefe':varFirmante;'Base Firma Jefe':varApressTemporal})))
;;
SaveData(colFirmas;"ColeccionFirmas");;SaveData(colFirmaRapida;"ColFirmaRapida");;
Reset(Pen_Firmas);;Reset(Radio1);;Reset(TextInput3);;Notify("Firma agregada";Success)
Originally, I didn't use any of the last variables (varCargo, varFirmante, varArchivoFirma, varApressTemporal), but since I needed to identify whenever one of those 3 people signed and save the data accordingly to each role, that was the only way I could think of... and it is working, it is patching the correct columns when each of them signs.
My variable gets created

colFirmas gets populated correctly

but the patch function... shows me the appres text.

And this is a major problem for me. Since this is an offline app, I must store all data to later convert it, apply JSON function and send it to power automate.
This is the patch I had started building to create my final collection (this is only the image columns... my colBaseSP has like 20 columns, all of them text expect for these ones):
ForAll(
colBaseSP;
Collect(
colFullDatos;
{
'Base Firma Operador': Mid(
JSON(
ThisRecord.'Base Firma Operador';
JSONFormat.IncludeBinaryData
);
Find(
",";
JSON(
ThisRecord.'Base Firma Operador';
JSONFormat.IncludeBinaryData
)
) + 1;
Len(
JSON(
ThisRecord.'Base Firma Operador';
JSONFormat.IncludeBinaryData
)
) - Find(
",";
JSON(
ThisRecord.'Base Firma Operador';
JSONFormat.IncludeBinaryData
)
) - 1
);
'Base Firma Encargado': Mid(
JSON(
ThisRecord.'Base Firma Encargado';
JSONFormat.IncludeBinaryData
);
Find(
",";
JSON(
ThisRecord.'Base Firma Encargado';
JSONFormat.IncludeBinaryData
)
) + 1;
Len(
JSON(
ThisRecord.'Base Firma Encargado';
JSONFormat.IncludeBinaryData
)
) - Find(
",";
JSON(
ThisRecord.'Base Firma Encargado';
JSONFormat.IncludeBinaryData
)
) - 1
);
'Base Firma Jefe': Mid(
JSON(
ThisRecord.'Base Firma Jefe';
JSONFormat.IncludeBinaryData
);
Find(
",";
JSON(
ThisRecord.'Base Firma Jefe';
JSONFormat.IncludeBinaryData
)
) + 1;
Len(
JSON(
ThisRecord.'Base Firma Jefe';
JSONFormat.IncludeBinaryData
)
) - Find(
",";
JSON(
ThisRecord.'Base Firma Jefe';
JSONFormat.IncludeBinaryData
)
) - 1
)
}
)
)
so... finally, this last collection colFullDatos is the one I was going to send to a new flow and finally get the report I need.
But... since the variable is not working when patching colBaseSP, none of the rest works and of course, no report.... what can I do??? I didn't know I couldn't patch an image variable... maybe it can be done, and I am doing all wrong... I have no idea... but I have been trying to find a way for a while now and it is really driving me crazy...
Can you help me?? do you have any other approachs that I can try??? this is like my 5th attempt of rebuilding the whole thing and finding a different way... but totally helpless...
Thank you so much in advance!!!