Hello I am trying to build an offline canvas App.
On Start of Power Apps I have the following code:
//Load Sites
Set(CurrentItemIndex, 0);
Clear(colSites);
//Check if device is online
If(Connection.Connected,
ClearCollect(
colQuestions,
Remedials_Question
);
Set(Site,"["& Substitute(Substitute(Remedials_Sites.Run().sites,"[",""),"]","")&"]");
ClearCollect(colSites, ForAll(Table(ParseJSON(Site)),
{cnReference: Text(Value.SiteUPRN),
cnName: Text(Value.SiteName)}));
SaveData(colSites,"cachesites"),
LoadData(colSites,"cachesites",true)
);
LoadData(colResponses,"Load responses")
- SiteScreen
I have a gallery glrSites: Items: FirstN(SortByColumns(Search(colSites, SearchSites.Text, "AssetName","Asset"), "AssetName",SortOrder.Ascending),8)
Navigate('Form Screen');Reset(SearchSites)
2. FormScreen
On visible of this screen I have the following code Set(CurrentGalleryItem,First(glrQuestions_hidden.AllItems));
I have added one gallery glrQuestions_hidden:Items: SortByColumns(colQuestions,"Item_No",SortOrder.Ascending) and another gallery glrResponses:Items: CurrentGalleryItem.
The glrResponses has a set of 20 questions and for each question the user should select as a response the green button, the red button or the grey button. The Green button has the following code on Select: If( glrResponses.Selected.ID in Distinct( colResponses, QuestionID ), //Update collection with form data Patch( colResponses, {QuestionID: ThisItem.ID}, {Answer: "Green"} ), Collect( colResponses, { SiteUprn: varCurrentRecord.cnReference, AuditDate: Today(), QuestionID: ThisItem.ID, Answer: "Green", AddComments: AddComments.Text } ) ); SaveData( colResponses, "cacheresponses" ); Set( CurrentGalleryItem, If( CurrentGalleryItem.ID = Last(glrQuestions_hidden.AllItems).Item_No, First(glrQuestions_hidden.AllItems), First( Filter( glrQuestions_hidden.AllItems, Item_No > CurrentGalleryItem.Item_No ) ) ) ); If( itemnumber_glrResponses.Text = "17", Navigate('Loading Screen') ); The red button has on select: If(glrResponses.Selected.ID in Distinct(colResponses,QuestionID), Patch(colResponses,{QuestionID:ThisItem.ID},{Answer:"Red"}), Collect(colResponses, {SiteUprn: varCurrentRecord.cnReference, AuditDate:Today(), QuestionID:ThisItem.ID, Answer:"Red", AddComments:AddComments.Text})); SaveData(colResponses,"cacheresponses"); Set(CurrentGalleryItem,If(CurrentGalleryItem.ID=Last(glrQuestions_hidden.AllItems).Item_No, First(glrQuestions_hidden.AllItems), First(Filter(glrQuestions_hidden.AllItems, Item_No > CurrentGalleryItem.Item_No)))); If(CurrentGalleryItem.Item_No>17, Navigate('Loading Screen')); If( itemnumber_glrResponses.Text = "17", Navigate('Loading Screen') ). The grey button on Select If(glrResponses.Selected.ID in Distinct(colResponses,QuestionID), Patch(colResponses,{QuestionID:ThisItem.ID},{Answer:"N/A"}), Collect(colResponses, {SiteUprn: varCurrentRecord.cnReference, AuditDate:Today(), QuestionID:ThisItem.ID, Answer:"N/A", AddComments:AddComments.Text})); SaveData(colResponses,"cacheresponses"); Set(CurrentGalleryItem,If(CurrentGalleryItem.ID=Last(glrQuestions_hidden.AllItems).Item_No, First(glrQuestions_hidden.AllItems), First(Filter(glrQuestions_hidden.AllItems, Item_No > CurrentGalleryItem.Item_No)))); If( itemnumber_glrResponses.Text = "17", Navigate('Loading Screen') )
On the left arrow I have the following code:
On the right arrow I have the following code:
3. Loading Screen.
This screen displays all the questions and responses from the user when they have responded the last question and I also give them the ability to edit the responses.
When the user selects edit the app shows a new gallery:
and On Select of Green, Red and grey button I have the following code:
Green button: Patch(colResponses,glrShowResponses.Selected, {SiteUprn:glrShowResponses.Selected.SiteUprn,
QuestionID:glrShowResponses.Selected.QuestionID,
Answer:"Green",
AddComments:AddComments_2.Text});
SaveData(colResponses,"cacheresponses");
UpdateContext({varPopup:false})
Red button: Patch(colResponses,glrShowResponses.Selected, {SiteUprn:glrShowResponses.Selected.SiteUprn,
QuestionID:glrShowResponses.Selected.QuestionID,
Answer:"Red",
AddComments:AddComments_2.Text});
SaveData(colResponses,"cacheresponses");
UpdateContext({varPopup:false})
Grey button: Patch(colResponses,glrShowResponses.Selected, {SiteUprn:glrShowResponses.Selected.SiteUprn,
QuestionID:glrShowResponses.Selected.QuestionID,
Answer:"N/A",
AddComments:AddComments_2.Text});
SaveData(colResponses,"cacheresponses");
UpdateContext({varPopup:false})
I tested the app being offline in my mobile but it seems like is not working at all. I am very confused with what I have found online.
I would like to succeed the following:
1.To SaveData and Load Data for the responses and the edit responses that the user has applied.
2. When the user get online and open the app to upload the responses to SharePoint List.
Apologies for my long long post, I am looking forward to seeing your response.
Many Thanks,

Report
All responses (
Answers (