Posts

Creating a Unique ID from Power app before saving the item.

Image
 Scenario: Creating a unique ID befoere saving the item in Power Apps. This is a very small snippet but it works well and even survive the cache issue in powerapps. Put in the code in the OnSelect property of the button Set(randomLowest,1); Set(randomHighest,9999999); Set(varID, RoundDown(Rand()*(randomHighest -randomLowest +1)+randomLowest,0)) Put the below code on the default code of the input text Text(varEmpID,"0000000") Simple and sweet.

Prevent overlapping of entered time by the user.

Image
      Usecase: User wants to clock in his claims, and for this he has to lock in his time period for work on that claim. The system should validate if this timeperiod has already been entered by him or not, and hence prevents him/her for entering overlapping timeperiod claims. Solution: I tried various approaches to begin with, like saving a list with 24 fields each representing one hour. And then when claim was punched in the flow was to update the time period for that claim. This was just a basic solution and was rigid. Also it could not handle claims if the timeperiod was in hours and minutes like 1hr 30 mins for a claim.  So i needed something which was more dynamic and flexible in the approach. Also, i am a firm believer of the fact, that if something is incorrect the best solution is to refrain user from entering it inside the system. That way, you dont have to deal with fixing with it later. Yup i know i am lazy. The below solution leverages collections. First i create a collect

Error 429- Rate limit is exceeded, Try again after 5 seconds.

The dynamic operation request to API 'sharepointonline' operation 'GetTable' failed with status code '429'. This may indicate invalid input parameters. Error response: { "statusCode": 429, "message": "Rate limit is exceeded. Try again in 22 seconds. Please see https://docs.microsoft.com/azure/logic-apps/handle-throttling-problems-429-errors for more details." } When you have too many API calls by the flow, the Power automate flow triggers this Error 429. But i have seen this error exception being thrown, even without say 600 API calls per connection per minute. When your list structure either has below use cases. 1. Multiple Update Item in the flow. 2. Calling other flows from the same flow. 3. Having branches in the flow, which are either creating or updating sharepoint list. Fix: There is no available fix for this apart form change in the design of the flows.  A user voiced was also raised for this but i see it as declined. https:

Moving PowerApps Attachments to a SharePoint Library using Power Automate flow.

Image
  Use Case :  Move the attached files to a SharePoint library rather than saving them as a SharePoint list item attachment. Solution: A gain the simplest solution is to create a Power Automate flow which runs on items creation. Add the action "Get Attachments" This will take in Site Address, List Name and the ID of the recently created item. So the catch is to add this action just after the When an item is created or modified step. Then we need to add the Get Attachment Content action. This action is also straight forward, it again takes in your address list name, ID and a File Identifier. The File Identifier is nothing but the Id for the previous step. Also, as soon you add it, Apply to each will wrap it. Next step is to add Create file action. This is again straight forward, just provide the Address, Folder Path (basically the SharePoint library you wish to save your attachment.), File Name and the File content.  File content is the output of your previous step. And thats i

Bulk Ops in Power Apps

Image
Scenario: User wants bulk operations like status change to multiple items in Power Apps. The data for this is saved in SharePoint online lists or Data verse. So first thing first, let just design a simple app. Our app will have a gallery on the screen, this gallery will be linked to a SharePoint online list. Then we will add checkbox field in the gallery and also put in few labels to show data values of the respective list. Next we need to go to the OnCheck property of this checkbox control. Here what we will do is create a collection and add the selected item on it. Code for this will look something like this Collect(collectionName, ThisItem) Similarly, we will now proceed to the OnUncheck property code for it will look something like  Remove(collectionName,ThisItem). So what we are trying to do in here is that on check of the checkbox we are adding the selected item from the gallery into your collection, named as collectionName in above code. Next we add two button on the screen, in

A type named 'SP.Data.TestListListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type.

Image
 Scenario: Trying to update a SharePoint list item using Send an HTTP request to Sharepoint action in Power Automate. This is an exception case, and i am writing it only to save someone's else time. Normally we can use Power Automate to GET, POST, PATCH & DELETE sharepoint list items. There are standard syntax, you need to follow to do it. The above title is an exception when your list name has a space when you create it. But when you delete that space later your Send HTTP request to SharePoint starts giving an error.  To be more clear i had a list called Master_Timesheet. And all i was doing was calling a flow from a Power App button and passing the listitem ID as parameter to the flow Something like this. FlowName.Run(ThisItem.ID) But to my surprise i was getting the below error. A type named 'SP.Data.Master_TimesheetListItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type. Initially i thought that i must hav

How to reset a datepicker control in PowerApps?

Image
 Scenario: Simple reset a date picker control. Issue, you can't use normal Reset() function to reset the datepicker control. Solution: Simple create a variable Set(varResetCD, True) and use this variable to update the reset property of DatePicker control. The below Reset() won't work in case of datepicker control We need to create a variable and use it at the Reset property of the datepicker control. Also, if you still see some text inside your date field there are two other places you need to check in one is the datepicker control advanced properties. In the above screenshot all you need to do is clear InputTextPlaceholder. And then select the control and check the DefaultDate property of the date.  This should be set to Today(), you can also change it to something like below If(varResetCD,Blank(),Today()) What this does is sets the control to blank if the variable you have declared above is true.