web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Help with Offline canv...
Power Apps
Unanswered

Help with Offline canvas app

(0) ShareShare
ReportReport
Posted on by 83

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")

anna2109_1-1699280624106.png

 

  1. SiteScreen
    I have a gallery glrSites: Items: FirstN(SortByColumns(Search(colSites, SearchSites.Text, "AssetName","Asset"), "AssetName",SortOrder.Ascending),8)
    anna2109_2-1699280867328.png
On Select of next arrow I have the following codeSet(varCurrentRecord, ThisItem);
Navigate('Form Screen');Reset(SearchSites)
2. FormScreen
anna2109_3-1699281060923.png

 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:

anna2109_1-1699349248965.png

 

 On the right arrow I have the following code:

anna2109_2-1699349364116.png

 

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.

anna2109_4-1699281355711.png

When the user selects edit the app shows a new gallery:

anna2109_5-1699281484604.png

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,



Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 519 Most Valuable Professional

#2
11manish Profile Picture

11manish 489

#3
Haque Profile Picture

Haque 327

Last 30 days Overall leaderboard