├── .forceignore ├── .gitignore ├── .prettierignore ├── .prettierrc ├── .vim-force.com └── session.properties ├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── LICENSE ├── README.md ├── config └── project-scratch-def.json ├── dxorgcreate ├── force-app └── main │ └── default │ ├── applications │ ├── Web_2_Any_Object.app-meta.xml │ └── Web_Form_To_Anything.app-meta.xml │ ├── classes │ ├── WEB_Form2AnyObject_Ctrl.cls │ ├── WEB_Form2AnyObject_Ctrl.cls-meta.xml │ ├── WEB_Form2AnyObject_Ctrl_Test.cls │ ├── WEB_Form2AnyObject_Ctrl_Test.cls-meta.xml │ ├── WEB_FormAnyObject_REST.cls │ ├── WEB_FormAnyObject_REST.cls-meta.xml │ ├── WEB_FormAnyObject_REST_Test.cls │ └── WEB_FormAnyObject_REST_Test.cls-meta.xml │ ├── flexipages │ └── Web_2_Any_Object_UtilityBar.flexipage-meta.xml │ ├── layouts │ └── Web2Any_Sample__c-Web2Any Sample Layout.layout-meta.xml │ ├── lwc │ └── .eslintrc.json │ ├── objects │ └── Web2Any_Sample__c │ │ ├── Web2Any_Sample__c.object-meta.xml │ │ ├── fields │ │ ├── Email__c.field-meta.xml │ │ ├── First_Name__c.field-meta.xml │ │ ├── Last_Name__c.field-meta.xml │ │ └── Phone__c.field-meta.xml │ │ └── listViews │ │ └── All.listView-meta.xml │ ├── pages │ ├── WEB_Form2AnyObject_Page.page │ └── WEB_Form2AnyObject_Page.page-meta.xml │ ├── permissionsets │ └── Web2Any.permissionset-meta.xml │ └── tabs │ ├── Web2Any_Sample__c.tab-meta.xml │ └── Web2Anything.tab-meta.xml ├── heroku-web ├── home.html └── index.php ├── img ├── apex_class_guest.png ├── enable_apex_rest1.png ├── pkg_install.png ├── site_domain.png ├── site_domain1.png ├── site_domain2.png ├── site_setup1.png ├── site_setup2.png └── web2any_config.png ├── pkg └── package.xml ├── scripts ├── apex │ └── hello.apex ├── cmd │ └── dxorgcreate ├── html │ └── SampleForm.html └── soql │ └── account.soql └── sfdx-project.json /.forceignore: -------------------------------------------------------------------------------- 1 | # List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status 2 | # More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm 3 | # 4 | 5 | package.xml 6 | 7 | # LWC configuration files 8 | **/jsconfig.json 9 | **/.eslintrc.json 10 | 11 | # LWC Jest 12 | **/__tests__/** 13 | 14 | # Ignore Profile related changes in DX 15 | **profilePasswordPolicies** 16 | **profiles** 17 | **profileSessionSettigs** 18 | **sites** 19 | **staticresources** 20 | **components** 21 | 22 | # Component 23 | AppSwitcher.appMenu 24 | 25 | # Ignore selected auto gen APEX classes related to Site 26 | force-app/main/default/classes/ChangePasswordController.cls 27 | force-app/main/default/classes/ChangePasswordControllerTest.cls 28 | force-app/main/default/classes/ForgotPasswordController.clc 29 | force-app/main/default/classes/ForgotPasswordControllerTest.cls 30 | force-app/main/default/classes/MyProfilePageController.cls 31 | force-app/main/default/classes/MyProfilePageControllerTest.cls 32 | force-app/main/default/classes/SiteLoginController.cls 33 | force-app/main/default/classes/SiteLoginControllerTest.cls 34 | force-app/main/default/classes/SiteRegisterController.cls 35 | force-app/main/default/classes/SiteRegisterControllerTest.cls 36 | 37 | # Ignore selected autogen pages related to Site 38 | force-app/main/default/pages/AnswersHome.page 39 | force-app/main/default/pages/BandwidthExceeded.page 40 | force-app/main/default/pages/ChangePassword.page 41 | force-app/main/default/pages/Exception.page 42 | force-app/main/default/pages/FileNotFound.page 43 | force-app/main/default/pages/ForgotPassword.page 44 | force-app/main/default/pages/ForgotPasswordConfirm.page 45 | force-app/main/default/pages/IdeasHome.page 46 | force-app/main/default/pages/InMaintenance.page 47 | force-app/main/default/pages/MyProfilePage.page 48 | force-app/main/default/pages/SiteLogin.page 49 | force-app/main/default/pages/SiteRegister.page 50 | force-app/main/default/pages/SiteRegisterConfirm.page 51 | force-app/main/default/pages/SiteTemplate.page 52 | force-app/main/default/pages/StdExceptionTemplate.page 53 | force-app/main/default/pages/Unauthorized.page 54 | force-app/main/default/pages/UnderConstruction.page -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This file is used for Git repositories to specify intentionally untracked files that Git should ignore. 2 | # If you are not using git, you can delete this file. For more information see: https://git-scm.com/docs/gitignore 3 | # For useful gitignore templates see: https://github.com/github/gitignore 4 | 5 | # Salesforce cache 6 | .sfdx/ 7 | .localdevserver/ 8 | 9 | # LWC VSCode autocomplete 10 | **/lwc/jsconfig.json 11 | 12 | # Logs 13 | logs 14 | *.log 15 | npm-debug.log* 16 | yarn-debug.log* 17 | yarn-error.log* 18 | 19 | # Dependency directories 20 | node_modules/ 21 | 22 | # Eslint cache 23 | .eslintcache 24 | 25 | # MacOS system files 26 | .DS_Store 27 | .project 28 | .salesforce 29 | .settings 30 | node_modules 31 | .idea 32 | destroy.sh 33 | envvars.sh 34 | test.sh 35 | salesforcedx.sh 36 | .vscode 37 | mdapiout 38 | test.yml 39 | 40 | # Windows system files 41 | Thumbs.db 42 | ehthumbs.db 43 | [Dd]esktop.ini 44 | $RECYCLE.BIN/ 45 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # List files or directories below to ignore them when running prettier 2 | # More information: https://prettier.io/docs/en/ignore.html 3 | # 4 | 5 | .sfdx 6 | .localdevserver -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "none", 3 | "overrides": [ 4 | { 5 | "files": "**/lwc/**/*.html", 6 | "options": { "parser": "lwc" } 7 | }, 8 | { 9 | "files": "*.{cmp,page,component}", 10 | "options": { "parser": "html" } 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.vim-force.com/session.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/.vim-force.com/session.properties -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "salesforce.salesforcedx-vscode", 4 | "redhat.vscode-xml", 5 | "dbaeumer.vscode-eslint", 6 | "esbenp.prettier-vscode" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Launch Apex Replay Debugger", 9 | "type": "apex-replay", 10 | "request": "launch", 11 | "logFile": "${command:AskForLogFileName}", 12 | "stopOnEntry": true, 13 | "trace": true 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "search.exclude": { 3 | "**/node_modules": true, 4 | "**/bower_components": true, 5 | "**/.sfdx": true 6 | }, 7 | "eslint.nodePath": "/Users/iandrosov/.vscode/extensions/salesforce.salesforcedx-vscode-lwc-47.16.0/node_modules" 8 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Igor Androsov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Salesforce Web2AnyObject App 2 | 3 | This guide helps Salesforce developers or admins to deploy/install and configure Web2Any Object utility. 4 | This app enables a webform to post data to any Object similar function as web2case or web2lead. 5 | 6 | Supported in Classic and Lightning versions of UI. 7 | 8 | This app makes use of Force.com public sites and REST API to send data from any web form. Form HTML code can be generated by this app or created manually based on the template provided later in this document. 9 | 10 | This app has been updated to DX project and use of API version 47.0 Winter20 release. 11 | 12 | Force.com site is required to be configured on target org, this is not part of this project and must be created manually. MyDomain must be enabled for this package. 13 | 14 | ## Application Use 15 | 16 | To use this app navigate to Web 2 Any app in the app launcher. 17 | select Web2Anything tab - this is a Visual Force page that will help to generate your web form HTML code. 18 | 19 | 1. Select a site 20 | 2. Select the target Object 21 | 3. Select multiple fields from the Object fields 22 | 4. Generate HTML 23 | 5. Copy generated HTML and insert styles to match a hosted web site 24 | ![Setup](img/web2any_config.png) 25 | 26 | Here is an example of an HTML form generated by Web2AnyObject utility. User needs to replace the form action URL with target ORG site URL 27 | 28 | ``` 29 |
30 | 31 | 32 | 33 |
34 |
35 |
36 | 37 |
38 | 39 | ``` 40 | 41 | For testing this application a sample custom object `Web2Any_Sample` is provided. For a quick test user can define a form to send data to this object. 42 | NOTES: User can choose any object available on the list to use as target for this form. 43 | 44 | ## Installation Instructions 45 | 46 | There are two ways to install Web2AnyObject App: 47 | 48 | - [Using Salesforce DX](#installing-web2anyobject-using-salesforce-dx): This is the recommended installation option. Use this option if you are a developer who may want to customize the app and may contribute to this project's code. 49 | - [Using an Unlocked Package](#installing-web2anyobject-using-an-unlocked-package): This option allows anybody to install and use the Permission Navigator App without installing a local development environment. 50 | 51 | ## Installing Web2AnyObject using Salesforce DX 52 | 53 | 1. Set up your environment. Follow the steps in the [Quick Start: Lightning Web Components](https://trailhead.salesforce.com/content/learn/projects/quick-start-lightning-web-components/) Trailhead project. The steps include: 54 | 55 | - Sign up for a developer org and enable Dev Hub 56 | - Install the latest version of the Salesforce CLI 57 | - Install Visual Studio Code 58 | - Install the Visual Studio Code Salesforce extensions, including the Lightning Web Components extension 59 | 60 | Follow these steps to setup this app in the scratch org for development. Alternatively you can use shell script from Step 3 `dxorgcreate` 61 | 62 | 1. If you haven't already done so, authenticate with your Developer hub org and provide it with an alias, example (devhub): 63 | 64 | ``` 65 | sfdx force:auth:web:login -d -a devhub 66 | ``` 67 | 68 | 1. Clone the salesforce-web-to-any-object repository: 69 | 70 | ``` 71 | git clone https://github.com/iandrosov/salesforce-web-to-any-object 72 | cd salesforce-web-to-any-object 73 | ``` 74 | 75 | 1. Create a scratch org and provide it with an alias (**web2any** in the command below): 76 | 77 | ``` 78 | sfdx force:org:create -s -f config/project-scratch-def.json -a web2any 79 | ``` 80 | 81 | 1. Push the app source code to your scratch org: 82 | 83 | ``` 84 | sfdx force:source:push 85 | ``` 86 | 87 | 1. Open the scratch org: 88 | 89 | ``` 90 | sfdx force:org:open 91 | ``` 92 | 1. In the new scratch org navigate to Permission Sets settings and assign Web2Any to your system admin user account that grants access to the app and tabs. 93 | `sfdx force:user:permset:assign -n Web2Any` 94 | 95 | 96 | 1. In App Launcher, select the **Web 2 Any Object** app. 97 | 98 | 99 | ## Installing Web2AnyObject using an Unlocked Package 100 | 101 | 1. [Sign up](https://www.salesforce.com/form/signup/) for a Developer org or use your existing sandbox, enable My Domain, and deploy it to all users. 102 | 103 | 1. Click [this link](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t3Z000001ae1EQAQ) to install the unlocked package in your target Production or Developer org `(login.nnnnn.com)`. 104 | 105 | 1. To install in sandbox or other type of org append following to instance URL: `https:///packaging/installPackage.apexp?p0=04t3Z000001ae1EQAQ` 106 | ![Installation](img/pkg_install.png) 107 | 1. Select **Install for Admin Users** 108 | 109 | 1. Assign your user a permission set `Web2Any` 110 | 111 | 1. In App Launcher, select the **Web 2 Any Object** app. 112 | 113 | ## After Install Manual Configuration 114 | 115 | This package requires Admin manual configuration 116 | 117 | 1. Navigate to Org Settings->Sites and select site domain. (Can use existing site) 118 | ![Site domain](img/site_domain1.png) 119 | 1. Create New site with name and select Site Home page (any page will work, example In Maintenance), leave all other configurations as default. 120 | ![Site Settings](img/site_setup1.png) 121 | 1. Using Public Access setting add REST Apex class `WEB_FormAnyObject_REST` to Guest User profile 122 | ![APEX Access](img/enable_apex_rest1.png) 123 | 1. Activate new site, if it is not active. 124 | 125 | ## Known Issues 126 | 127 | 1. If you install a package and launch the app but do not see Web Form target site, the site was not created. Solution is to follow instruction post-install and configure new Force.com site. 128 | 129 | 2. If your org is using several Communities you may see multiple sites to choose. Community site can be used as a gateway for Web2Any but, user needs to configure public NOT_Authenticated access for Guest User on the site. 130 | 131 | 132 | -------------------------------------------------------------------------------- /config/project-scratch-def.json: -------------------------------------------------------------------------------- 1 | { 2 | "orgName": "Web2AnyObject", 3 | "edition": "Developer", 4 | "features": [] 5 | } 6 | -------------------------------------------------------------------------------- /dxorgcreate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get org argument 4 | DX_ALIAS="$1" 5 | DEVHUB="DevHub" 6 | 7 | # Create DX Org for Project 8 | sfdx force:org:create --setdefaultusername --setalias $DX_ALIAS --definitionfile config/project-scratch-def.json -d 20 9 | ## sfdx force:org:create --setdefaultusername --setalias pkg1 --definitionfile config/project-scratch-def.json -d 30 10 | 11 | # Push Project source to new org 12 | sfdx force:source:push -u $DX_ALIAS 13 | 14 | # ssign admin permission for SCrtch org 15 | sfdx force:user:permset:assign -n Web2Any 16 | 17 | # Add sample data -------------------------------------------------------------------------------- /force-app/main/default/applications/Web_2_Any_Object.app-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #78179B 5 | false 6 | 7 | LEX App enable web 2 any custom or standard object 8 | Large 9 | false 10 | false 11 | 12 | Standard 13 | Web2Anything 14 | Web2Any_Sample__c 15 | Lightning 16 | Web_2_Any_Object_UtilityBar 17 | 18 | -------------------------------------------------------------------------------- /force-app/main/default/applications/Web_Form_To_Anything.app-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | standard-home 4 | Application provides ability for the org to generate simple web forms for any object and create data records from the requests posted by the form. Same functionality as Web2Lead but for any object. 5 | false 6 | false 7 | 8 | Web2Anything 9 | 10 | -------------------------------------------------------------------------------- /force-app/main/default/classes/WEB_Form2AnyObject_Ctrl.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Controller class for UI component to build 3 | * a web form to submit data for new records via Force.com sites 4 | * URL and REST service 5 | * 6 | * Author: i.Androsov 7 | */ 8 | public class WEB_Form2AnyObject_Ctrl { 9 | 10 | public String selectedSiteURL {get; set;} 11 | public String selectedObject {get; set;} 12 | public String[] selectedFields {get; set;} 13 | public String webForm {get{return getWebFormHTML();} set;} 14 | public Boolean displayFields {get; set;} 15 | public Boolean displayWebForm {get; set;} 16 | private Map fieldMap = new Map(); 17 | private String[] standardObjects = new String[]{'Account','Contact','Asset','Idea','Opportunity','Campaign', 'Case'}; 18 | 19 | public WEB_Form2AnyObject_Ctrl(){ 20 | this.displayFields = false; 21 | this.displayWebForm = false; 22 | } 23 | 24 | public List getSiteURL(){ 25 | List options = new List(); 26 | 27 | List siteLst = [SELECT Id, Name, MasterLabel, Description, Subdomain, UrlPathPrefix, Status FROM Site where Status = 'Active' LIMIT 100]; 28 | List siteIdList = new List (); 29 | Map siteMap = new Map(); 30 | for (Site s : siteLst){ 31 | siteIdList.add(s.Id); 32 | siteMap.put(s.Id,s.Name); 33 | } 34 | 35 | List siteDetailList = [SELECT Id, DurableId, SecureUrl FROM SiteDetail WHERE DurableId IN :siteIdList]; 36 | for (SiteDetail d : siteDetailList){ 37 | options.add(new SelectOption(d.SecureUrl, (String)siteMap.get(d.DurableId))); 38 | } 39 | options.sort(); 40 | return options; 41 | } 42 | 43 | 44 | 45 | public List getObjectList(){ 46 | List options = new List(); 47 | //iterate through the object list and build a list of objects 48 | List oTokens = Schema.getGlobalDescribe().values() ; 49 | for( Integer i = 0; i < oTokens.size() ; i++ ){ 50 | Schema.DescribeSObjectResult t = oTokens.get(i).getDescribe(); 51 | if(isValidWebFormObject(t)){ 52 | options.add(new SelectOption(t.getName(),t.getName()+'-'+t.getLabel())); 53 | } 54 | } 55 | options.sort(); 56 | return options; 57 | } 58 | 59 | 60 | public List getFieldList(){ 61 | List options = new List(); 62 | if (this.selectedObject != null && this.selectedObject.length() > 0){ 63 | this.fieldMap = new Map(); 64 | Map gd = Schema.getGlobalDescribe(); 65 | Schema.SObjectType obj = gd.get(this.selectedObject); 66 | Schema.DescribeSObjectResult R = obj.getDescribe(); 67 | 68 | Map mp = R.fields.getMap(); 69 | List field_list = mp.values(); 70 | 71 | for (Schema.SObjectField f : field_list){ 72 | Schema.DescribeFieldResult df = f.getDescribe(); 73 | if (df.isCustom() && df.isCreateable()){ 74 | options.add(new SelectOption(df.getName(),df.getName())); 75 | } else { 76 | if (df.isNameField() && !df.isAutoNumber()){ 77 | options.add(new SelectOption(df.getName(),df.getName())); 78 | }else if (!df.isIdLookup() && df.isCreateable() && df.isAccessible() && !df.isCalculated() 79 | && !df.isDeprecatedAndHidden() && !df.isExternalId() && !df.isAutoNumber()){ 80 | options.add(new SelectOption(df.getName(),df.getName())); 81 | } 82 | } 83 | this.fieldMap.put(df.getName(),df.getLabel()); 84 | } 85 | } 86 | options.sort(); 87 | return options; 88 | } 89 | 90 | public String getWebFormHTML(){ 91 | 92 | String htm = '
\n'; 93 | htm += '\n'; 94 | htm += '\n'; 95 | htm += '\n'; 96 | 97 | // Add fields to web form 98 | if (this.selectedFields != null){ 99 | for (String s : selectedFields){ 100 | if (this.fieldMap.containsKey(s)){ 101 | String df = this.fieldMap.get(s); 102 | htm += '
\n'; 103 | } 104 | } 105 | } 106 | 107 | htm += '\n'; 108 | htm += '
\n'; 109 | 110 | return htm; 111 | } 112 | 113 | public PageReference updateObjectFields(){ 114 | this.displayFields = true; 115 | 116 | return null; 117 | } 118 | 119 | public PageReference createWebForm(){ 120 | this.displayWebForm = true; 121 | this.displayFields = true; 122 | return null; 123 | } 124 | 125 | /** 126 | * Check if object can be really created woth web form 127 | */ 128 | private Boolean isValidWebFormObject(Schema.DescribeSObjectResult t){ 129 | Boolean rc = false; 130 | if (t.isCreateable() && t.isAccessible() && !t.isCustomSetting()){ 131 | if (t.isCustom()){ 132 | rc = true; 133 | }else if (matchName(t.getName())){ 134 | rc = true; 135 | } 136 | } 137 | return rc; 138 | } 139 | 140 | private Boolean matchName(String nm){ 141 | for(String s : this.standardObjects){ 142 | if (nm.equals(s)){ 143 | return true; 144 | } 145 | //if (nm.equals('Contact') || nm.equals('Account') || nm.equals('Asset') || nm.equals('Idea') || nm.equals('Opportunity')) 146 | // rc = true; 147 | } 148 | return false; 149 | } 150 | 151 | } -------------------------------------------------------------------------------- /force-app/main/default/classes/WEB_Form2AnyObject_Ctrl.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 47.0 4 | 5 | 1 6 | 4 7 | ERD 8 | 9 | 10 | 1 11 | 2 12 | Field_Trip 13 | 14 | Active 15 | 16 | -------------------------------------------------------------------------------- /force-app/main/default/classes/WEB_Form2AnyObject_Ctrl_Test.cls: -------------------------------------------------------------------------------- 1 | @isTest 2 | private class WEB_Form2AnyObject_Ctrl_Test { 3 | 4 | @isTest 5 | public static void testWEBForm2AnythingController(){ 6 | WEB_Form2AnyObject_Ctrl myController = new WEB_Form2AnyObject_Ctrl(); 7 | 8 | List siteOptions = myController.getSiteURL(); 9 | List objectOptions = myController.getObjectList(); 10 | myController.selectedObject = 'Account'; 11 | myController.selectedSiteURL = 'https://natsteeldemo-developer-edition.na9.force.com/'; 12 | List fldList = myController.getFieldList(); 13 | myController.selectedFields = new String[]{'name'}; 14 | String html = myController.getWebFormHTML(); 15 | 16 | PageReference pr = myController.updateObjectFields(); 17 | pr = myController.createWebForm(); 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /force-app/main/default/classes/WEB_Form2AnyObject_Ctrl_Test.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 47.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /force-app/main/default/classes/WEB_FormAnyObject_REST.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Class provide REST Webservice that will be open to Use in Sites 3 | * to enable Web To Any Record feature 4 | * This clsss is required to be allowed for use in Sites for not authenticated Web Forms. 5 | * 6 | * Service will accept request form a generated Web Form to create a record 7 | * of any given type. Field mapping will be automatic based on the field name in the form 8 | * that matches teh fields names in the Object. 9 | * NOTE: HTML Forms cannot validate user input to be of some type therefore assume it is all Text 10 | * if user has special data types like Date, Numbers, currency to input as part of web form 11 | * need to provide custom JavaScript or other type of validation l;ogic to HTML page. It will not be 12 | * generated automatically 13 | * https://natsteeldemo-developer-edition.na9.force.com/ 14 | */ 15 | 16 | @RestResource(urlMapping='/anyobject') 17 | global class WEB_FormAnyObject_REST { 18 | //global static String doAnything(RestRequest req) 19 | @HttpPost 20 | global static String doAnything() { 21 | 22 | // This is documented in Summer 12 REST API Developer Guide but does not work 23 | // RestContext fields are allways null 24 | RestRequest req = RestContext.request; 25 | // RestContext.response.addHeader('Content-Type', 'text/plain'); 26 | // RestContext.response.responseBody = Blob.valueOf('Hello '+name+' Type: '+o_type); 27 | 28 | if (req != null){ 29 | if (req.params != null){ 30 | //String name = req.params.get('name'); 31 | String o_type = req.params.get('otype'); 32 | 33 | String parm = 'params:'; 34 | SObject obj = createObject(o_type); 35 | Set keys = req.params.keySet(); 36 | for(String s : keys){ 37 | if (!s.equalsIgnoreCase('submit') && !s.equalsIgnoreCase('otype') && !s.equalsIgnoreCase('retURL') && !s.equalsIgnoreCase('encoding')){ 38 | String val = req.params.get(s); 39 | if (val != null && val.length() > 0) 40 | obj.put(s,val); 41 | } 42 | parm += ' '+s+': '+req.params.get(s); 43 | } 44 | insert obj; 45 | 46 | return 'Success: Created record of Type: '+o_type; 47 | }else{ 48 | String uri = req.requestURI; 49 | return 'ERROR: Request Parameters not found. URI: '+uri; 50 | } 51 | }else{ 52 | return 'ERROR: Request object not found'; 53 | } 54 | } 55 | 56 | private static SObject createObject(String typeName) { 57 | Schema.SObjectType targetType = Schema.getGlobalDescribe().get(typeName); 58 | if (targetType == null) { 59 | // throw an exception 60 | 61 | } 62 | return targetType.newSObject(); 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /force-app/main/default/classes/WEB_FormAnyObject_REST.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 47.0 4 | 5 | 1 6 | 4 7 | ERD 8 | 9 | 10 | 1 11 | 2 12 | Field_Trip 13 | 14 | Active 15 | 16 | -------------------------------------------------------------------------------- /force-app/main/default/classes/WEB_FormAnyObject_REST_Test.cls: -------------------------------------------------------------------------------- 1 | @isTest 2 | private class WEB_FormAnyObject_REST_Test { 3 | @isTest 4 | static void testWEBForm2AnythingController(){ 5 | 6 | // Prep data 7 | RestRequest req = new RestRequest(); 8 | RestResponse resp = new RestResponse(); 9 | //String s = WEB_FormAnyObject_REST.doAnything(req, resp); 10 | req.params.put('otype','Account'); 11 | req.params.put('name','ai_Web2AnyTest'); 12 | RestContext.request = req; 13 | 14 | String s = WEB_FormAnyObject_REST.doAnything(); 15 | 16 | } 17 | } -------------------------------------------------------------------------------- /force-app/main/default/classes/WEB_FormAnyObject_REST_Test.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 47.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /force-app/main/default/flexipages/Web_2_Any_Object_UtilityBar.flexipage-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | utilityItems 5 | Region 6 | 7 | 8 | backgroundComponents 9 | Background 10 | 11 | Web 2 Any Object UtilityBar 12 | 15 | UtilityBar 16 | 17 | -------------------------------------------------------------------------------- /force-app/main/default/layouts/Web2Any_Sample__c-Web2Any Sample Layout.layout-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | false 6 | true 7 | 8 | 9 | 10 | Readonly 11 | Name 12 | 13 | 14 | Edit 15 | First_Name__c 16 | 17 | 18 | Edit 19 | Last_Name__c 20 | 21 | 22 | Edit 23 | Email__c 24 | 25 | 26 | Edit 27 | Phone__c 28 | 29 | 30 | 31 | 32 | Edit 33 | OwnerId 34 | 35 | 36 | 37 | 38 | 39 | false 40 | false 41 | true 42 | 43 | 44 | 45 | Readonly 46 | CreatedById 47 | 48 | 49 | 50 | 51 | Readonly 52 | LastModifiedById 53 | 54 | 55 | 56 | 57 | 58 | false 59 | false 60 | true 61 | 62 | 63 | 64 | 65 | 66 | 67 | TASK.SUBJECT 68 | TASK.WHO_NAME 69 | ACTIVITY.TASK 70 | TASK.DUE_DATE 71 | TASK.STATUS 72 | TASK.PRIORITY 73 | CORE.USERS.FULL_NAME 74 | RelatedActivityList 75 | 76 | 77 | TASK.SUBJECT 78 | TASK.WHO_NAME 79 | ACTIVITY.TASK 80 | TASK.DUE_DATE 81 | CORE.USERS.FULL_NAME 82 | TASK.LAST_UPDATE 83 | RelatedHistoryList 84 | 85 | false 86 | false 87 | false 88 | false 89 | false 90 | 91 | -------------------------------------------------------------------------------- /force-app/main/default/lwc/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@salesforce/eslint-config-lwc/recommended"] 3 | } 4 | -------------------------------------------------------------------------------- /force-app/main/default/objects/Web2Any_Sample__c/Web2Any_Sample__c.object-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Accept 5 | Default 6 | 7 | 8 | Accept 9 | Large 10 | Default 11 | 12 | 13 | Accept 14 | Small 15 | Default 16 | 17 | 18 | CancelEdit 19 | Default 20 | 21 | 22 | CancelEdit 23 | Large 24 | Default 25 | 26 | 27 | CancelEdit 28 | Small 29 | Default 30 | 31 | 32 | Clone 33 | Default 34 | 35 | 36 | Clone 37 | Large 38 | Default 39 | 40 | 41 | Clone 42 | Small 43 | Default 44 | 45 | 46 | Delete 47 | Default 48 | 49 | 50 | Delete 51 | Large 52 | Default 53 | 54 | 55 | Delete 56 | Small 57 | Default 58 | 59 | 60 | Edit 61 | Default 62 | 63 | 64 | Edit 65 | Large 66 | Default 67 | 68 | 69 | Edit 70 | Small 71 | Default 72 | 73 | 74 | List 75 | Default 76 | 77 | 78 | List 79 | Large 80 | Default 81 | 82 | 83 | List 84 | Small 85 | Default 86 | 87 | 88 | New 89 | Default 90 | 91 | 92 | New 93 | Large 94 | Default 95 | 96 | 97 | New 98 | Small 99 | Default 100 | 101 | 102 | SaveEdit 103 | Default 104 | 105 | 106 | SaveEdit 107 | Large 108 | Default 109 | 110 | 111 | SaveEdit 112 | Small 113 | Default 114 | 115 | 116 | Tab 117 | Default 118 | 119 | 120 | Tab 121 | Large 122 | Default 123 | 124 | 125 | Tab 126 | Small 127 | Default 128 | 129 | 130 | View 131 | Default 132 | 133 | 134 | View 135 | Large 136 | Default 137 | 138 | 139 | View 140 | Small 141 | Default 142 | 143 | false 144 | SYSTEM 145 | Deployed 146 | true 147 | true 148 | false 149 | false 150 | false 151 | true 152 | true 153 | true 154 | true 155 | 156 | 157 | W-{0000} 158 | 159 | AutoNumber 160 | 161 | Web2Any Sample 162 | 163 | ReadWrite 164 | Public 165 | 166 | -------------------------------------------------------------------------------- /force-app/main/default/objects/Web2Any_Sample__c/fields/Email__c.field-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Email__c 4 | false 5 | 6 | 100 7 | false 8 | false 9 | Text 10 | false 11 | 12 | -------------------------------------------------------------------------------- /force-app/main/default/objects/Web2Any_Sample__c/fields/First_Name__c.field-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | First_Name__c 4 | false 5 | 6 | 30 7 | false 8 | false 9 | Text 10 | false 11 | 12 | -------------------------------------------------------------------------------- /force-app/main/default/objects/Web2Any_Sample__c/fields/Last_Name__c.field-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Last_Name__c 4 | false 5 | 6 | 100 7 | false 8 | false 9 | Text 10 | false 11 | 12 | -------------------------------------------------------------------------------- /force-app/main/default/objects/Web2Any_Sample__c/fields/Phone__c.field-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Phone__c 4 | false 5 | 6 | false 7 | false 8 | Phone 9 | 10 | -------------------------------------------------------------------------------- /force-app/main/default/objects/Web2Any_Sample__c/listViews/All.listView-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | All 4 | NAME 5 | Email__c 6 | First_Name__c 7 | Last_Name__c 8 | Everything 9 | 10 | 11 | -------------------------------------------------------------------------------- /force-app/main/default/pages/WEB_Form2AnyObject_Page.page: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /force-app/main/default/pages/WEB_Form2AnyObject_Page.page-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 47.0 4 | 5 | 6 | 1 7 | 4 8 | ERD 9 | 10 | 11 | 1 12 | 2 13 | Field_Trip 14 | 15 | 16 | -------------------------------------------------------------------------------- /force-app/main/default/permissionsets/Web2Any.permissionset-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Web_2_Any_Object 5 | true 6 | 7 | 8 | Web_Form_To_Anything 9 | true 10 | 11 | Web 2 Any Object app 12 | 13 | true 14 | Web2Any_Sample__c.Email__c 15 | true 16 | 17 | 18 | true 19 | Web2Any_Sample__c.First_Name__c 20 | true 21 | 22 | 23 | true 24 | Web2Any_Sample__c.Last_Name__c 25 | true 26 | 27 | 28 | true 29 | Web2Any_Sample__c.Phone__c 30 | true 31 | 32 | false 33 | 34 | 35 | true 36 | false 37 | true 38 | true 39 | false 40 | Web2Any_Sample__c 41 | false 42 | 43 | 44 | Web2Any_Sample__c 45 | Visible 46 | 47 | 48 | Web2Anything 49 | Visible 50 | 51 | 52 | true 53 | ViewRoles 54 | 55 | 56 | true 57 | ViewSetup 58 | 59 | 60 | -------------------------------------------------------------------------------- /force-app/main/default/tabs/Web2Any_Sample__c.tab-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | Custom57: Building Block 5 | 6 | -------------------------------------------------------------------------------- /force-app/main/default/tabs/Web2Anything.tab-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Web Form Generation Tab creates HTML forms 4 | 5 | Custom67: Gears 6 | WEB_Form2AnyObject_Page 7 | 8 | -------------------------------------------------------------------------------- /heroku-web/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 49 | 50 | 51 |
53 | 54 | 55 | 56 | 57 | 58 | 59 |
60 | 61 |
62 | 63 |
64 |

65 | 66 | Please select a file to attach:
67 | 68 |
69 | 70 | 71 |

72 | 73 | -------------------------------------------------------------------------------- /heroku-web/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /img/apex_class_guest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/apex_class_guest.png -------------------------------------------------------------------------------- /img/enable_apex_rest1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/enable_apex_rest1.png -------------------------------------------------------------------------------- /img/pkg_install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/pkg_install.png -------------------------------------------------------------------------------- /img/site_domain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/site_domain.png -------------------------------------------------------------------------------- /img/site_domain1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/site_domain1.png -------------------------------------------------------------------------------- /img/site_domain2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/site_domain2.png -------------------------------------------------------------------------------- /img/site_setup1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/site_setup1.png -------------------------------------------------------------------------------- /img/site_setup2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/site_setup2.png -------------------------------------------------------------------------------- /img/web2any_config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iandrosov/salesforce-web-to-any-object/5bc8879656c789e439d02faef7704c8b5ad93936/img/web2any_config.png -------------------------------------------------------------------------------- /pkg/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WEB_Form2AnyObject_Ctrl 5 | WEB_FormAnyObject_REST 6 | ApexClass 7 | 8 | 9 | WEB_Form2AnyObject_Page 10 | ApexPage 11 | 12 | 13 | Web_Form_To_Anything 14 | CustomApplication 15 | 16 | 17 | Web2Anything 18 | CustomTab 19 | 20 | 23.0 21 | 22 | -------------------------------------------------------------------------------- /scripts/apex/hello.apex: -------------------------------------------------------------------------------- 1 | // Use .apex files to store anonymous Apex. 2 | // You can execute anonymous Apex in VS Code by selecting the 3 | // apex text and running the command: 4 | // SFDX: Execute Anonymous Apex with Currently Selected Text 5 | // You can also execute the entire file by running the command: 6 | // SFDX: Execute Anonymous Apex with Editor Contents 7 | 8 | string tempvar = 'Enter_your_name_here'; 9 | System.debug('Hello World!'); 10 | System.debug('My name is ' + tempvar); -------------------------------------------------------------------------------- /scripts/cmd/dxorgcreate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get org argument 4 | DX_ALIAS="$1" 5 | DEVHUB="DevHub" 6 | 7 | # Create DX Org for Project 8 | sfdx force:org:create --setdefaultusername --setalias $DX_ALIAS --definitionfile config/project-scratch-def.json -d 2 9 | ## sfdx force:org:create --setdefaultusername --setalias web --definitionfile config/project-scratch-def.json -d 30 10 | 11 | # Push Project source to new org 12 | sfdx force:source:push -u $DX_ALIAS 13 | 14 | # assign permission for Scratch org 15 | sfdx force:user:permset:assign -n Web2Any 16 | 17 | # Add sample data -------------------------------------------------------------------------------- /scripts/html/SampleForm.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 |
7 |
8 |
9 | 10 |
-------------------------------------------------------------------------------- /scripts/soql/account.soql: -------------------------------------------------------------------------------- 1 | // Use .soql files to store SOQL queries. 2 | // You can execute queries in VS Code by selecting the 3 | // query text and running the command: 4 | // SFDX: Execute SOQL Query with Currently Selected Text 5 | 6 | SELECT Id, Name FROM Account; -------------------------------------------------------------------------------- /sfdx-project.json: -------------------------------------------------------------------------------- 1 | { 2 | "packageDirectories": [ 3 | { 4 | "path": "force-app", 5 | "default": true, 6 | "package": "Web2Any", 7 | "versionName": "ver 1.1", 8 | "versionNumber": "1.1.0.NEXT" 9 | } 10 | ], 11 | "namespace": "", 12 | "sfdcLoginUrl": "https://login.salesforce.com", 13 | "sourceApiVersion": "47.0", 14 | "packageAliases": { 15 | "Web2Any": "0Ho3Z000000XZB5SAO", 16 | "Web2Any@1.0.0-1": "04t3Z000001ae19QAA", 17 | "Web2Any@1.1.0-1": "04t3Z000001ae1EQAQ" 18 | } 19 | } --------------------------------------------------------------------------------