Skip to content

Commit

Permalink
Merge pull request #1574 from alexed1/CheckBlankFields
Browse files Browse the repository at this point in the history
CheckBlankFields
  • Loading branch information
alexed1 authored Sep 22, 2024
2 parents 62c6ac1 + c827c13 commit c36fb2c
Show file tree
Hide file tree
Showing 23 changed files with 305 additions and 0 deletions.
15 changes: 15 additions & 0 deletions flow_action_components/CheckBlankFields/.forceignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
#

package.xml

# LWC configuration files
**/jsconfig.json
**/.eslintrc.json

# LWC Jest
**/__tests__/**
**/tsconfig.json

**/*.ts
4 changes: 4 additions & 0 deletions flow_action_components/CheckBlankFields/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run precommit
18 changes: 18 additions & 0 deletions flow_action_components/CheckBlankFields/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Salesforce DX Project: Next Steps

Now that you’ve created a Salesforce DX project, what’s next? Here are some documentation resources to get you started.

## How Do You Plan to Deploy Your Changes?

Do you want to deploy a set of changes, or create a self-contained application? Choose a [development model](https://developer.salesforce.com/tools/vscode/en/user-guide/development-models).

## Configure Your Salesforce DX Project

The `sfdx-project.json` file contains useful configuration information for your project. See [Salesforce DX Project Configuration](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) in the _Salesforce DX Developer Guide_ for details about this file.

## Read All About It

- [Salesforce Extensions Documentation](https://developer.salesforce.com/tools/vscode/)
- [Salesforce CLI Setup Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_setup.meta/sfdx_setup/sfdx_setup_intro.htm)
- [Salesforce DX Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_intro.htm)
- [Salesforce CLI Command Reference](https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"orgName": "Demo company",
"edition": "Developer",
"features": ["EnableSetPasswordInApi"],
"settings": {
"lightningExperienceSettings": {
"enableS1DesktopEnabled": true
},
"mobileSettings": {
"enableS1EncryptedStoragePref2": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": ["@salesforce/eslint-plugin-aura"],
"extends": ["plugin:@salesforce/eslint-plugin-aura/recommended"],
"rules": {
"vars-on-top": "off",
"no-unused-expressions": "off"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public class CheckBlankFields {

public class Input {
@InvocableVariable(required=true)
public SObject record;
@InvocableVariable(required=true)
public String fieldApiNames;
}

public class Output {
@InvocableVariable
public String blankFieldsListString;
}

@InvocableMethod(label='Check Blank Fields')
public static List<Output> checkBlankFields(List<Input> inputList) {
List<Output> outputList = new List<Output>();
for (Input input : inputList) {
SObject record = input.record;
String fieldApiNames = input.fieldApiNames;
if (record != null && fieldApiNames != null) {
List<String> fieldApiNameList = fieldApiNames.split(',');
List<String> blankFieldsList = new List<String>();
for (String fieldApiName : fieldApiNameList) {
Schema.SObjectField field = record.getSObjectType().getDescribe().fields.getMap().get(fieldApiName);
if (field != null && (record.get(fieldApiName) == null || String.valueOf(record.get(fieldApiName)).trim() == '')) {
blankFieldsList.add(field.getDescribe().getLabel());
}
}
Output output = new Output();
output.blankFieldsListString = String.join(blankFieldsList, ', ');
outputList.add(output);
}
}
return outputList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@isTest
public class CheckBlankFieldsTest {

static testMethod void testCheckBlankFields() {
// Create an account with some blank fields
Account acct = new Account(Name='Test Account', Industry='');
insert acct;
// Update Industry to be blank
acct.Industry = '';
update acct;
// Create the input object
CheckBlankFields.Input input = new CheckBlankFields.Input();
input.record = acct;
input.fieldApiNames = 'Industry';
// Create a list of inputs
List<CheckBlankFields.Input> inputList = new List<CheckBlankFields.Input>();
inputList.add(input);
// Call the checkBlankFields method
List<CheckBlankFields.Output> outputList = CheckBlankFields.checkBlankFields(inputList);
// Verify the output
System.assertEquals(1, outputList.size());
CheckBlankFields.Output output = outputList.get(0);
System.assertEquals('Industry', output.blankFieldsListString, 'Expected: Industry, Actual: ' + output.blankFieldsListString);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>61.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": ["@salesforce/eslint-config-lwc/recommended"],
"overrides": [
{
"files": ["*.test.js"],
"rules": {
"@lwc/lwc/no-unexpected-wire-adapter-usages": "off"
},
"env": {
"node": true
}
}
]
}
6 changes: 6 additions & 0 deletions flow_action_components/CheckBlankFields/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { jestConfig } = require('@salesforce/sfdx-lwc-jest/config');

module.exports = {
...jestConfig,
modulePathIgnorePatterns: ['<rootDir>/.localdevserver']
};
36 changes: 36 additions & 0 deletions flow_action_components/CheckBlankFields/manifest/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
<types>
<members>*</members>
<name>ApexPage</name>
</types>
<types>
<members>*</members>
<name>ApexTestSuite</name>
</types>
<types>
<members>*</members>
<name>ApexTrigger</name>
</types>
<types>
<members>*</members>
<name>AuraDefinitionBundle</name>
</types>
<types>
<members>*</members>
<name>LightningComponentBundle</name>
</types>
<types>
<members>*</members>
<name>StaticResource</name>
</types>
<version>61.0</version>
</Package>
41 changes: 41 additions & 0 deletions flow_action_components/CheckBlankFields/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "salesforce-app",
"private": true,
"version": "1.0.0",
"description": "Salesforce App",
"scripts": {
"lint": "eslint **/{aura,lwc}/**/*.js",
"test": "npm run test:unit",
"test:unit": "sfdx-lwc-jest",
"test:unit:watch": "sfdx-lwc-jest --watch",
"test:unit:debug": "sfdx-lwc-jest --debug",
"test:unit:coverage": "sfdx-lwc-jest --coverage",
"prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
"prettier:verify": "prettier --check \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
"postinstall": "husky install",
"precommit": "lint-staged"
},
"devDependencies": {
"@lwc/eslint-plugin-lwc": "^1.1.2",
"@prettier/plugin-xml": "^3.2.2",
"@salesforce/eslint-config-lwc": "^3.2.3",
"@salesforce/eslint-plugin-aura": "^2.0.0",
"@salesforce/eslint-plugin-lightning": "^1.0.0",
"@salesforce/sfdx-lwc-jest": "^3.1.0",
"eslint": "^8.11.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^27.6.0",
"husky": "^8.0.3",
"lint-staged": "^15.1.0",
"prettier": "^3.1.0",
"prettier-plugin-apex": "^2.0.1"
},
"lint-staged": {
"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}": [
"prettier --write"
],
"**/{aura,lwc}/**/*.js": [
"eslint"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
if "%1" neq "" set packageName=%1
@echo on
sfdx package:create -v lexhost --name "%packageName%" --path force-app --package-type Unlocked
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
if "%1" neq "" set version=%1
@echo on
sfdx package:version:create -v lexhost -w 20 -x -c -n %version%.0 -d force-app\
5 changes: 5 additions & 0 deletions flow_action_components/CheckBlankFields/packaging/Details.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
if "%1" neq "" set packageName=%1
if "%2" neq "" set version=%2
@echo on
sfdx package:version:report -v lexhost --package "%packageName%@%version%"
5 changes: 5 additions & 0 deletions flow_action_components/CheckBlankFields/packaging/Promote.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
if "%1" neq "" set packageName=%1
if "%2" neq "" set version=%2
@echo on
sfdx package:version:promote -v lexhost --package "%packageName%@%version%"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off
if "%1" neq "" goto skipprompt
set /p packageName="Set Package Name: "
goto exit
:skipprompt
set packageName=%1
:exit
echo Package Name: %packageName%
@echo on
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off
if "%1" neq "" goto skipprompt
set /p version="Set Version Number: "
goto exit
:skipprompt
set version=%1
:exit
echo Version: %version%
@echo on
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
echo Package Name: %packageName%
echo Version: %version%
@echo on
10 changes: 10 additions & 0 deletions flow_action_components/CheckBlankFields/scripts/apex/hello.apex
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Use .apex files to store anonymous Apex.
// You can execute anonymous Apex in VS Code by selecting the
// apex text and running the command:
// SFDX: Execute Anonymous Apex with Currently Selected Text
// You can also execute the entire file by running the command:
// SFDX: Execute Anonymous Apex with Editor Contents

string tempvar = 'Enter_your_name_here';
System.debug('Hello World!');
System.debug('My name is ' + tempvar);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Use .soql files to store SOQL queries.
// You can execute queries in VS Code by selecting the
// query text and running the command:
// SFDX: Execute SOQL Query with Currently Selected Text

SELECT Id, Name FROM Account
20 changes: 20 additions & 0 deletions flow_action_components/CheckBlankFields/sfdx-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"packageDirectories": [
{
"path": "force-app",
"default": true,
"package": "CheckBlankFields",
"versionName": "ver 0.1",
"versionNumber": "0.1.0.NEXT",
"versionDescription": ""
}
],
"name": "CheckBlankFields",
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "61.0",
"packageAliases": {
"CheckBlankFields": "0Ho5G000000sXuPSAU",
"CheckBlankFields@1.0.0": "04t5G000004fz8BQAQ"
}
}

0 comments on commit c36fb2c

Please sign in to comment.