Skip to content

Instantly share code, notes, and snippets.

View hicglobalsolutions's full-sized avatar
🎯
Focusing

HIC Global Solutions hicglobalsolutions

🎯
Focusing
View GitHub Profile
@hicglobalsolutions
hicglobalsolutions / Create app.js file
Created April 4, 2024 13:02
Now one of the most crucial parts of this component to create a new file called app.js
// Import necessary libraries
var express = require('express'); // Express.js for building the server
var bodyParser = require('body-parser'); // Body-parser for parsing the request body
var cors = require('cors'); // CORS for handling cross-origin requests
// Import the Google Cloud client library
const {PubSub} = require('@google-cloud/pubsub'); // Google Cloud Pub/Sub for real-time messaging
// Initialize Express.js
var app = express();
@hicglobalsolutions
hicglobalsolutions / Create a Thank You .html page.
Created April 4, 2024 12:54
Now create a Thank you page which will redirect us to our salesforce site and there we will see our published data.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Thank You</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact form</title>
<!-- Include Font Awesome CSS for icons -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
<!-- Include Google Fonts (Roboto) for styling -->
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" rel="stylesheet">
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Lightning Component Bundle is configured to be exposed on the Home Page. -->
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>58.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>
// Import necessary modules from the Lightning Web Components (LWC) and Apex
import { LightningElement, wire, track } from 'lwc';
import getObjectMethod from '@salesforce/apex/getObjects.getObjectMethod';
// Define the PolymorphicRecordPicker class
export default class PolymorphicRecordPicker extends LightningElement {
// Track the target objects, selected target, current selected record ID, and loading state
@track targetObjects = [
{ label: 'Account', value: 'Account' },
{ label: 'Contact', value: 'Contact' },
@isTest
public class getObjectsTest {
@isTest static void testGetObjectMethod() {
// Call the method to test
List<String> result = getObjects.getObjectMethod();
System.assertNotEquals(null, result, 'The returned list should not be null');
System.assert(result.size() > 0, 'The returned list should not be empty');
}
}
public with sharing class getObjects {
// The @AuraEnabled annotation makes the method accessible from Lightning component
@AuraEnabled(cacheable=true)
public static List<String> getObjectMethod() {
// Initialize a list to hold the names of all accessible, createable, and updateable custom objects
List<String> customObjectNames = new List<String>();
// Loop through all sObject types in the org
for(Schema.SObjectType objType : Schema.getGlobalDescribe().Values()) {
/* Container with relative positioning */
.loading-container {
position: relative;
display: inline-block;
}
/* Spinner container with absolute positioning and centered content */
.spinner-container {
position: absolute;
top: 0;
<template>
<!-- Main container -->
<div class="loading-container">
<!-- Loading spinner shown when isLoading is true -->
<template if:true={isLoading}>
<div class="spinner-container">
<lightning-spinner alternative-text="Loading" size="medium"></lightning-spinner>
</div>
</template>
<!-- Lightning card for the dynamic record picker -->
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Lightning Component Bundle is configured to be exposed on the Home Page. -->
<LightningComponentBundle xmlns="<http://soap.sforce.com/2006/04/metadata>">
<apiVersion>58.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>