Skip to content
Gunjan Datta edited this page Feb 20, 2023 · 8 revisions

Static Variables (src/strings.ts)

This file contains the static data for the project, which is referenced by the other code. The setContext method is for SPFx/Teams solutions. The context information is used to update the REST API library, to ensure we can execute requests to it. The sourceUrl is optional, when the solution is not in the same web where the solution is deployed.

import { ContextInfo } from "gd-sprest-bs";

// Sets the context information
// This is for SPFx or Teams solutions
export const setContext = (context, sourceUrl?: string) => {
    // Set the context
    ContextInfo.setPageContext(context.pageContext);

    // Update the source url
    Strings.SourceUrl = sourceUrl || ContextInfo.webServerRelativeUrl;
}

/**
 * Global Constants
 */
const Strings = {
    AppElementId: "sp-dashboard",
    GlobalVariable: "SPDashboard",
    Lists: {
        Main: "Dashboard"
    },
    ProjectName: "SP Dashboard",
    ProjectDescription: "Created using the gd-sprest-bs library.",
    SourceUrl: ContextInfo.webServerRelativeUrl,
    Version: "0.1"
};
export default Strings;