tomssharepointdiscoveries
tomssharepointdiscoveries
Toms SharePoint Discoveries
345 posts
Just some SP and InfoPath discoveries which, if you use, you do so at your own risk!
Don't wanna be here? Send us removal request.
tomssharepointdiscoveries · 7 months ago
Text
Installing PnP.PowerShell trouble?
Do this instead:
Install-Module SharePointPnPPowerShellOnline -Scope CurrentUser UPDATE: This works but installs a legacy version. DO NOT USE.
Further update: Don't try to use PowerShell 5 with the latest version of PnP.PowerShell, it won't work. It needs 7.
Further update:
Make sure to close and restart powershell as anything installed wonn't show.
0 notes
tomssharepointdiscoveries · 11 months ago
Text
People Pickers not submitting or jsut working correctly on Teams app?
That's because the app is being hosted in Teams and you are drawing data from SharePoint probably? Yeah, different Id numbers for users. You will have to change your Person column in SharePoint to a string column, submit the email and name/title to that column and read back the email on EditItem invocation. FAFF!
0 notes
Text
Not getting anything from a data function in your other component?
I was doing an msGraph:
Tumblr media
and I wasn't getting qnything in the function. I was moving return around, but nothing. Then I realised that the const = new Image() declaration was INSIDE the final .then. I moved it out of the .then to the top of the entire function. It started sending shit back. Classic rookie error of JavaScript closure.
0 notes
Text
When using multiple comboboxes to filter a gallery in PowerApps
It's down to how the 'values' are gotten from the combobox Items property. The 2nd Or is referring to a combobox which gets it's values from an SP list by using Distinct. It wasn't working with just Distinct so I added .Value on the end of the Items property:
Distinct( LaptopsRedesign, LaptopStatus.Value )
Here is the filter for the gallery:
Filter( LaptopsRedesign, And( Or( IsBlank(cmboSiteFilter.SelectedItems), IsEmpty(cmboSiteFilter.SelectedItems), SiteText in cmboSiteFilter.SelectedItems.Title ), Or( IsBlank(cmboLaptopStatus.SelectedItems), IsEmpty(cmboLaptopStatus.SelectedItems), LaptopStatus.Value in cmboLaptopStatus.SelectedItems.Value ) ) )
0 notes
Text
When creating a Teams Toolkit proj
It wouldn't initialise when opening the proj in Vis Stu. So I found the correct folder. Just keep trying....
0 notes
Text
Destructuring an object (get a property value from an object)
Lets say you have an object but you only need a value from it:
do this:
const { siteUrl } = stuff;
0 notes
Text
Trouble getting a data service func to show in another component?
export const getEmailsMsGraph = async (msGraphcontext: any): Promise<any> => {
    let emails: any[] = [];
    return await msGraphcontext.msGraphClientFactory
      .getClient('3')
      .then(async (client: MSGraphClientV3) => {
        // get information about the current user from the Microsoft Graph
        await client
          .api('/me/messages')
          .top(5)
          .orderby("receivedDateTime desc")
          .get((error, messages: any, rawResponse?: any) => {
            console.log(error, 'error');
            // _renderEmailList(messages.value);
            emails = messages.value;
          });
        return emails;
      });
  };
0 notes
tomssharepointdiscoveries · 2 years ago
Text
Destructuring to change an array
I was getting hubsite from sharepoint and needed to cut down the amount of stuff I was getting into a useable array:
I used: const newObjArray: any[] = [] const hubsites: IHubSiteInfo[] = await _sp.hubsites();
hubsites.map(({Title, ID}) => {
return newObjArray.push({Title, ID})
})
return newObjArray
0 notes
tomssharepointdiscoveries · 2 years ago
Text
Want to use includes or some etc?
Add "ES2020" to tsconfig.json within "lib"
0 notes
tomssharepointdiscoveries · 2 years ago
Text
Preserving state probs?
Finding that when you change page in your app it doesn't preserve state in your fields? You probably have a parent component which isn't controlling state. The Child is. Hoist up the state to the parent. As in, put the state in the higher component to the child. You will have to create the handler function and the state in the parent and pass them both down as props.
0 notes
tomssharepointdiscoveries · 2 years ago
Text
No localised files
If you are getting an error when installing spfx-controls-react from pnpjs, make sure to add the control strings to config.json, but make sure it starts with ../
0 notes
tomssharepointdiscoveries · 2 years ago
Text
Get a webpart to be centered on an SP page
Put "supportsfullbleed": true
0 notes
tomssharepointdiscoveries · 2 years ago
Text
To style a fluent ui/office fabric icon
const addIcon2: IIconProps = {
iconName: 'NavigateExternalInline',
styles: {
root: { paddingBottom: '5px' }
}
};
0 notes
tomssharepointdiscoveries · 2 years ago
Text
Pasting to a SharePoint list from Excel
Click Edit in Grid view.
Click in next empty field (if there are existing items)
Copy from Excel
Make sure there is no flashing cursor in SP list or it will paste into the cell not the table.
Paste
0 notes
tomssharepointdiscoveries · 2 years ago
Text
using MS Graphv3
Use the MSGraphClientV3 to connect to Microsoft Graph | Microsoft Learn
0 notes
tomssharepointdiscoveries · 2 years ago
Text
Getting "stale" state example
I was using a filter on a list of items from SP which I was getting from a parent component and accessing by using props.agents
I was advised not to do that (I thought, if the data is there then why bring it in again?) because what if that data changed while the app was in front of a user? If the data was refreshed when the Edit form was open, then it would be fresh. So I changed the data to be retrieved when the Edit form was opened.
So, I was still getting a stale output (although the term stale might not have applied here, it was more of a race state). When a drop down was selected it should filter the agents list. It was showing the last selected drop down item (which was wrong).
I had the filter function running within the _changeDropDown function. The filter looked like this:
const filterAgents = (obufilter: string) => {
        GetAgents().then(ag => {
            const filterAction = ag.filter(agents => {
                const opt = agents.AgentOBU.some((
                    { Title }) => Title === obufilter
                )
                console.log(opt, 'opt')
                return opt;
            });
            setFilteredAgents(filterAction);
            console.log(filterAction, 'filterAction');
        });
    };
And as mentioned this was run within the _changeDropdown function. So we changed it to:
const filterAgents = (obufilter: string) => {
        GetAgents().then(ag => {
            const filterAction = ag.filter(agents => {
                const opt = agents.AgentOBU.some((
                    { Title }) => Title === obufilter
                )
                console.log(opt, 'opt')
                return opt;
            }).map<IDropdownOption>(result => {
                return {
                    key: result.NameEmail,
                    text: result.NameTitle
                }
            });
            setFilteredAgents(filterAction);
            console.log(filterAction, 'filterAction');
        });
    };
const _changeOBU = (ev: React.FormEvent<HTMLDivElement>, option?: IDropdownOption, index?: number) => {
        setSelectedObuId(parseInt(option.id));
        setSelectedObu(option.text);
        filterAgents(option.text);
    };
As you can see we are directly passing the option.text into the filterAgents instead of not doing this!
0 notes
tomssharepointdiscoveries · 2 years ago
Text
Making Ajax requests SPFX
Chris O'Brien: Dealing with async REST API calls in the SharePoint Framework with Promises and HttpClient/jQuery AJAX (sharepointnutsandbolts.com)
0 notes