Initial commit
This commit is contained in:
commit
aa8e65b650
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
# This file is used for Git repositories to specify intentionally untracked files that Git should ignore.
|
||||||
|
# If you are not using git, you can delete this file. For more information see: https://git-scm.com/docs/gitignore
|
||||||
|
# For useful gitignore templates see: https://github.com/github/gitignore
|
||||||
|
|
||||||
|
# Salesforce cache
|
||||||
|
.sf/
|
||||||
|
.sfdx/
|
||||||
|
.localdevserver/
|
||||||
|
deploy-options.json
|
||||||
|
|
||||||
|
# LWC VSCode autocomplete
|
||||||
|
**/lwc/jsconfig.json
|
||||||
|
|
||||||
|
# LWC Jest coverage reports
|
||||||
|
coverage/
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# MacOS system files
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Windows system files
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
[Dd]esktop.ini
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Local environment variables
|
||||||
|
.env
|
||||||
|
|
||||||
|
# Python Salesforce Functions
|
||||||
|
**/__pycache__/
|
||||||
|
**/.venv/
|
||||||
|
**/venv/
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
npm run precommit
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
# List files or directories below to ignore them when running prettier
|
||||||
|
# More information: https://prettier.io/docs/en/ignore.html
|
||||||
|
#
|
||||||
|
|
||||||
|
**/staticresources/**
|
||||||
|
.localdevserver
|
||||||
|
.sfdx
|
||||||
|
.sf
|
||||||
|
.vscode
|
||||||
|
|
||||||
|
coverage/
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"trailingComma": "none",
|
||||||
|
"plugins": [
|
||||||
|
"prettier-plugin-apex",
|
||||||
|
"@prettier/plugin-xml"
|
||||||
|
],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": "**/lwc/**/*.html",
|
||||||
|
"options": { "parser": "lwc" }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": "*.{cmp,page,component}",
|
||||||
|
"options": { "parser": "html" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"salesforce.salesforcedx-vscode",
|
||||||
|
"redhat.vscode-xml",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"financialforce.lana"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Launch Apex Replay Debugger",
|
||||||
|
"type": "apex-replay",
|
||||||
|
"request": "launch",
|
||||||
|
"logFile": "${command:AskForLogFileName}",
|
||||||
|
"stopOnEntry": true,
|
||||||
|
"trace": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"search.exclude": {
|
||||||
|
"**/node_modules": true,
|
||||||
|
"**/bower_components": true,
|
||||||
|
"**/.sfdx": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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)
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"orgName": "Demo company",
|
||||||
|
"edition": "Developer",
|
||||||
|
"features": ["EnableSetPasswordInApi"],
|
||||||
|
"settings": {
|
||||||
|
"lightningExperienceSettings": {
|
||||||
|
"enableS1DesktopEnabled": true
|
||||||
|
},
|
||||||
|
"mobileSettings": {
|
||||||
|
"enableS1EncryptedStoragePref2": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
<aura:component controller="MyContactListController" implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
|
||||||
|
<aura:attribute name="recordId" type="Id" />
|
||||||
|
<aura:attribute name="Account" type="Account" />
|
||||||
|
<aura:attribute name="Contacts" type="List" />
|
||||||
|
<aura:attribute name="Columns" type="List" />
|
||||||
|
<aura:attribute name="editForm" type="boolean" default="false" />
|
||||||
|
<aura:handler name="init" value="{!this}" action="{!c.myAction}" />
|
||||||
|
<force:recordData aura:id="accountRecord"
|
||||||
|
recordId="{!v.recordId}"
|
||||||
|
targetFields="{!v.Account}"
|
||||||
|
layoutType="FULL"
|
||||||
|
/>
|
||||||
|
<div class="slds-box slds-text-heading_small">
|
||||||
|
<lightning:card iconName="standard:contact" title="{! 'Contact List for ' + v.Account.Name}"/>
|
||||||
|
<!-- Contact list goes here -->
|
||||||
|
<!-- Display contacts one by one -->
|
||||||
|
<div class="slds-docked_container_align-left">
|
||||||
|
<div class="slds-scrollable">
|
||||||
|
<div class="slds-docked-modal_composer slds-grid slds-grid_vertical-align-left slds-grid_align-left slds-is-open" role="dialog" aria-labelledby="dialog-heading-id-1" aria-describedby="dialog-content-id-1">
|
||||||
|
|
||||||
|
<aura:if isTrue="{!not(empty(v.Contacts))}">
|
||||||
|
<div class="slds-grid slds-wrap">
|
||||||
|
<aura:iteration items="{!v.Contacts}" var="contact">
|
||||||
|
<div class="slds-col slds-size_1-of-2">
|
||||||
|
<lightning:card title="{!contact.Name}" >
|
||||||
|
<div class="slds-grid slds-gutters">
|
||||||
|
<div class="slds-col slds-text-body_medium">
|
||||||
|
<span>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-06">
|
||||||
|
<div class="slds-box">
|
||||||
|
<div data-id="{!contact.Id}" class="slds-box">
|
||||||
|
<p class="slds-p-horizontal_small">
|
||||||
|
First Name: {!contact.Name}
|
||||||
|
</p>
|
||||||
|
<p class="slds-p-horizontal_small">
|
||||||
|
Phone: {!contact.Phone}
|
||||||
|
</p>
|
||||||
|
<p class="slds-p-horizontal_small">
|
||||||
|
Email: {!contact.Email}
|
||||||
|
</p>
|
||||||
|
<div class="slds-clearfix">
|
||||||
|
<lightning:button variant="brand" label="Edit" class="slds-float_ slds_right-m-left_x-small test"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</lightning:card>
|
||||||
|
</div>
|
||||||
|
</aura:iteration>
|
||||||
|
</div>
|
||||||
|
</aura:if>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aura:component>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<description>A Lightning Component Bundle</description>
|
||||||
|
</AuraDefinitionBundle>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
.THIS.test{
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
({
|
||||||
|
myAction: function(component, event, helper) {
|
||||||
|
component.set("v.Columns", [
|
||||||
|
{ label: "Name", fieldName: "Name", type: "text" },
|
||||||
|
{ label: "Email", fieldName: "Email", type: "email" },
|
||||||
|
{ label: "Phone", fieldName: "Phone", type: "phone" }
|
||||||
|
]);
|
||||||
|
var action = component.get("c.getContacts");
|
||||||
|
action.setParams({
|
||||||
|
recordId: component.get("v.recordId")
|
||||||
|
});
|
||||||
|
action.setCallback(this, function(response) {
|
||||||
|
var state = response.getState();
|
||||||
|
if (state === "SUCCESS") {
|
||||||
|
var contacts = response.getReturnValue();
|
||||||
|
component.set("v.Contacts", contacts);
|
||||||
|
} else {
|
||||||
|
// Handle error state here
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
<!-- add implements="forceCommunity:availableForAllPageTypes" to surface the component in community builder -->
|
||||||
|
<aura:component controller="LightningForgotPasswordController">
|
||||||
|
<aura:attribute name="usernameLabel" type="String" required="false" default="Username"/>
|
||||||
|
<aura:attribute name="submitButtonLabel" type="String" required="false" default="Reset Password"/>
|
||||||
|
<aura:attribute name="showError" type="Boolean" required="true" description="" default="false" access="private"/>
|
||||||
|
<aura:attribute name="errorMessage" type="String" required="false" description="" access="private"/>
|
||||||
|
<aura:attribute name="checkEmailUrl" type="String" required="true"/>
|
||||||
|
<aura:attribute name="expid" type="String" required="false" description="The branding experience ID" />
|
||||||
|
<aura:handler name="init" value="{!this}" action="{!c.initialize}"/>
|
||||||
|
<aura:handler event="c:setExpId" action="{!c.setExpId}"/>
|
||||||
|
<aura:dependency resource="c:setExpId" type="EVENT"/>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<aura:renderIf isTrue="{!v.showError}">
|
||||||
|
<div id="error">
|
||||||
|
<ui:outputRichText value="{!v.errorMessage}"/>
|
||||||
|
</div>
|
||||||
|
</aura:renderIf>
|
||||||
|
<div id="sfdc_username_container" class="sfdc">
|
||||||
|
<span id="sfdc_user" class="login-icon" data-icon="a"></span>
|
||||||
|
<ui:inputText value="" aura:id="username" placeholder="{!v.usernameLabel}" keyup="{!c.onKeyUp}" class="input sfdc_usernameinput sfdc"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sfdc">
|
||||||
|
<ui:button aura:id="submitButton" label="{!v.submitButtonLabel}" press="{!c.handleForgotPassword}" class="sfdc_button"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</aura:component>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<description>Sample Component for forgotPassword</description>
|
||||||
|
</AuraDefinitionBundle>
|
||||||
|
|
@ -0,0 +1,76 @@
|
||||||
|
.THIS #sfdc_username_container{
|
||||||
|
margin-bottom:10px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_user{
|
||||||
|
float:left;
|
||||||
|
width:23px;
|
||||||
|
height:25px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-left:2px;
|
||||||
|
margin:0px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS .login-icon {
|
||||||
|
color:#ccc;font-size:22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS button.sfdc_button {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #0070d2;
|
||||||
|
border-color: #357ebd;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
white-space: nowrap;
|
||||||
|
padding: 10px 12px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
font-weight: 300;
|
||||||
|
line-height: 1.42857143;
|
||||||
|
border-radius: 2px;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS button:hover {
|
||||||
|
background-color:#3276b1;
|
||||||
|
border-color:#285e8e;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS input {
|
||||||
|
margin-left:10px;
|
||||||
|
margin-top: 3px;
|
||||||
|
border: 0px solid transparent;
|
||||||
|
width: 70%;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #error {
|
||||||
|
text-align: center;
|
||||||
|
color:#FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS a {
|
||||||
|
color:white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.THIS a:hover {
|
||||||
|
color:white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<design:component label="Custom Forgot Password">
|
||||||
|
<design:attribute name="checkEmailUrl" default="./CheckPasswordResetEmail"/>
|
||||||
|
<design:attribute name="usernameLabel" default="Username"/>
|
||||||
|
<design:attribute name="submitButtonLabel" default="Reset Password"/>
|
||||||
|
</design:component>
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
({
|
||||||
|
handleForgotPassword: function (component, event, helpler) {
|
||||||
|
helpler.handleForgotPassword(component, event, helpler);
|
||||||
|
},
|
||||||
|
onKeyUp: function(component, event, helpler){
|
||||||
|
//checks for "enter" key
|
||||||
|
if (event.getParam('keyCode')===13) {
|
||||||
|
helpler.handleForgotPassword(component, event, helpler);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setExpId: function (component, event, helper) {
|
||||||
|
var expId = event.getParam('expid');
|
||||||
|
if (expId) {
|
||||||
|
component.set("v.expid", expId);
|
||||||
|
}
|
||||||
|
helper.setBrandingCookie(component, event, helper);
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize: function(component, event, helper) {
|
||||||
|
$A.get("e.siteforce:registerQueryEventMap").setParams({"qsToEvent" : helper.qsToEventMap}).fire();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
({
|
||||||
|
qsToEventMap: {
|
||||||
|
'expid' : 'e.c:setExpId'
|
||||||
|
},
|
||||||
|
|
||||||
|
handleForgotPassword: function (component, event, helpler) {
|
||||||
|
var username = component.find("username").get("v.value");
|
||||||
|
var checkEmailUrl = component.get("v.checkEmailUrl");
|
||||||
|
var action = component.get("c.forgotPassword");
|
||||||
|
action.setParams({username:username, checkEmailUrl:checkEmailUrl});
|
||||||
|
action.setCallback(this, function(a) {
|
||||||
|
var rtnValue = a.getReturnValue();
|
||||||
|
if (rtnValue != null) {
|
||||||
|
component.set("v.errorMessage",rtnValue);
|
||||||
|
component.set("v.showError",true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
setBrandingCookie: function (component, event, helpler) {
|
||||||
|
var expId = component.get("v.expid");
|
||||||
|
if (expId) {
|
||||||
|
var action = component.get("c.setExperienceId");
|
||||||
|
action.setParams({expId:expId});
|
||||||
|
action.setCallback(this, function(a){ });
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<aura:application >
|
||||||
|
|
||||||
|
</aura:application>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>60.0</apiVersion>
|
||||||
|
<description>A Lightning Component Bundle</description>
|
||||||
|
</AuraDefinitionBundle>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<aura:component implements="flexipage:availableForAllPageTypes" access="global">
|
||||||
|
<c:lms />
|
||||||
|
</aura:component>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>60.0</apiVersion>
|
||||||
|
<description>A Lightning Component Bundle</description>
|
||||||
|
</AuraDefinitionBundle>
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
<!-- add implements="forceCommunity:availableForAllPageTypes" to surface the component in community builder -->
|
||||||
|
<aura:component controller="LightningLoginFormController">
|
||||||
|
<aura:attribute name="showError" type="Boolean" required="true" description="" default="false" access="private"/>
|
||||||
|
<aura:attribute name="errorMessage" type="String" required="false" description="" access="private"/>
|
||||||
|
<aura:attribute name="startUrl" type="String" required="false" description="The url you go to after a successful login" />
|
||||||
|
<aura:attribute name="usernameLabel" type="String" required="false" default="Username"/>
|
||||||
|
<aura:attribute name="passwordLabel" type="String" required="false" default="Password"/>
|
||||||
|
<aura:attribute name="loginButtonLabel" type="String" required="false" default="Log in"/>
|
||||||
|
<aura:attribute name="expid" type="String" required="false" description="The branding experience ID" />
|
||||||
|
|
||||||
|
<aura:attribute name="forgotPasswordLabel" type="String" required="false" default="Forgot your password?"/>
|
||||||
|
<aura:attribute name="selfRegisterLabel" type="String" required="false" default="Not a member?"/>
|
||||||
|
<aura:attribute name="forgotPasswordUrl" type="String" required="false" default="/ForgotPassword"/>
|
||||||
|
<aura:attribute name="selfRegisterUrl" type="String" required="false" default="/SelfRegister"/>
|
||||||
|
|
||||||
|
<aura:attribute name="isUsernamePasswordEnabled" type="Boolean" access="private"/>
|
||||||
|
<aura:attribute name="isSelfRegistrationEnabled" type="Boolean" access="private"/>
|
||||||
|
<aura:attribute name="communityForgotPasswordUrl" type="String" access="private"/>
|
||||||
|
<aura:attribute name="communitySelfRegisterUrl" type="String" access="private"/>
|
||||||
|
|
||||||
|
<aura:registerevent name="sitePropagatedStartUrl" type="c:setStartUrl"/>
|
||||||
|
<aura:handler name="init" value="{!this}" action="{!c.initialize}"/>
|
||||||
|
<aura:dependency resource="c:setStartUrl" type="EVENT"/>
|
||||||
|
<!-- Please uncomment
|
||||||
|
<aura:dependency resource="siteforce:registerQueryEventMap" type="EVENT"/>
|
||||||
|
-->
|
||||||
|
<aura:handler event="c:setStartUrl" action="{!c.setStartUrl}"/>
|
||||||
|
<aura:handler event="c:setExpId" action="{!c.setExpId}"/>
|
||||||
|
<aura:dependency resource="c:setExpId" type="EVENT"/>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<aura:renderIf isTrue="{!v.isUsernamePasswordEnabled}">
|
||||||
|
<span>
|
||||||
|
<aura:renderIf isTrue="{!v.showError}">
|
||||||
|
<div id="error">
|
||||||
|
<ui:outputRichText value="{!v.errorMessage}"/>
|
||||||
|
</div>
|
||||||
|
</aura:renderIf>
|
||||||
|
</span>
|
||||||
|
<div id="sfdc_username_container" class="sfdc">
|
||||||
|
<span id="sfdc_user" class="login-icon" data-icon="a"></span>
|
||||||
|
<ui:inputText value="" aura:id="username" placeholder="{!v.usernameLabel}" keyup="{!c.onKeyUp}" class="input sfdc_usernameinput sfdc" label="{!v.usernameLabel}" labelClass="assistiveText"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="sfdc_password_container" class="sfdc">
|
||||||
|
<span id="sfdc_lock" class="login-icon sfdc" data-icon="c"></span>
|
||||||
|
<ui:inputSecret value="" aura:id="password" placeholder="{!v.passwordLabel}" keyup="{!c.onKeyUp}" class="input sfdc_passwordinput sfdc" label="{!v.passwordLabel}" labelClass="assistiveText"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="sfdc">
|
||||||
|
<ui:button aura:id="submitButton" label="{!v.loginButtonLabel}" press="{!c.handleLogin}" class="sfdc_button"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="sfdc_forgot" class="sfdc">
|
||||||
|
<span><a href="{!if(v.communityForgotPasswordUrl == null, v.forgotPasswordUrl, v.communityForgotPasswordUrl)}">{!v.forgotPasswordLabel}</a></span>
|
||||||
|
<aura:renderIf isTrue="{!v.isSelfRegistrationEnabled}">
|
||||||
|
<span style="float:right" ><a href="{!if(v.communitySelfRegisterUrl == null, v.selfRegisterUrl, v.communitySelfRegisterUrl)}">{!v.selfRegisterLabel}</a></span>
|
||||||
|
</aura:renderIf>
|
||||||
|
</div>
|
||||||
|
</aura:renderIf>
|
||||||
|
</div>
|
||||||
|
</aura:component>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<description>Sample Component for loginForm</description>
|
||||||
|
</AuraDefinitionBundle>
|
||||||
|
|
@ -0,0 +1,103 @@
|
||||||
|
.THIS #sfdc_username_container{
|
||||||
|
margin-bottom:10px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_user{
|
||||||
|
float:left;
|
||||||
|
width:23px;
|
||||||
|
height:25px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-left:2px;
|
||||||
|
margin:0px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_lock{
|
||||||
|
float:left;
|
||||||
|
width:23px;
|
||||||
|
height:25px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-left:2px;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #error {
|
||||||
|
text-align: center;
|
||||||
|
color:#FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS .login-icon {
|
||||||
|
color:#ccc;font-size:22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_password_container{
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS button.sfdc_button {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #0070d2;
|
||||||
|
border-color: #357ebd;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
white-space: nowrap;
|
||||||
|
padding: 10px 12px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
font-weight: 300;
|
||||||
|
line-height: 1.42857143;
|
||||||
|
border-radius: 2px;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS button:hover {
|
||||||
|
background-color:#3276b1;
|
||||||
|
border-color:#285e8e;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS button .label {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS input {
|
||||||
|
margin-left:10px;
|
||||||
|
margin-top: 3px;
|
||||||
|
border: 0px solid transparent;
|
||||||
|
width: 70%;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.THIS a {
|
||||||
|
color:white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.THIS a:hover {
|
||||||
|
color:white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS label.uiLabel-hidden {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<design:component label="Custom Login Form">
|
||||||
|
<design:attribute name="startUrl"/>
|
||||||
|
<design:attribute name="usernameLabel" default="Email"/>
|
||||||
|
<design:attribute name="passwordLabel" default="Password"/>
|
||||||
|
<design:attribute name="loginButtonLabel" default="Log in"/>
|
||||||
|
<design:attribute name="forgotPasswordLabel" default="Forgot your password?"/>
|
||||||
|
<design:attribute name="forgotPasswordUrl"/>
|
||||||
|
<design:attribute name="selfRegisterLabel" default="Not a member?"/>
|
||||||
|
<design:attribute name="selfRegisterUrl"/>
|
||||||
|
</design:component>
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
({
|
||||||
|
initialize: function(component, event, helper) {
|
||||||
|
$A.get("e.siteforce:registerQueryEventMap").setParams({"qsToEvent" : helper.qsToEventMap}).fire();
|
||||||
|
$A.get("e.siteforce:registerQueryEventMap").setParams({"qsToEvent" : helper.qsToEventMap2}).fire();
|
||||||
|
component.set('v.isUsernamePasswordEnabled', helper.getIsUsernamePasswordEnabled(component, event, helper));
|
||||||
|
component.set("v.isSelfRegistrationEnabled", helper.getIsSelfRegistrationEnabled(component, event, helper));
|
||||||
|
component.set("v.communityForgotPasswordUrl", helper.getCommunityForgotPasswordUrl(component, event, helper));
|
||||||
|
component.set("v.communitySelfRegisterUrl", helper.getCommunitySelfRegisterUrl(component, event, helper));
|
||||||
|
},
|
||||||
|
|
||||||
|
handleLogin: function (component, event, helpler) {
|
||||||
|
helpler.handleLogin(component, event, helpler);
|
||||||
|
},
|
||||||
|
|
||||||
|
setStartUrl: function (component, event, helpler) {
|
||||||
|
var startUrl = event.getParam('startURL');
|
||||||
|
if(startUrl) {
|
||||||
|
component.set("v.startUrl", startUrl);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setExpId: function (component, event, helper) {
|
||||||
|
var expId = event.getParam('expid');
|
||||||
|
if (expId) {
|
||||||
|
component.set("v.expid", expId);
|
||||||
|
}
|
||||||
|
helper.setBrandingCookie(component, event, helper);
|
||||||
|
},
|
||||||
|
|
||||||
|
onKeyUp: function(component, event, helpler){
|
||||||
|
//checks for "enter" key
|
||||||
|
if (event.getParam('keyCode')===13) {
|
||||||
|
helpler.handleLogin(component, event, helpler);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
navigateToForgotPassword: function(cmp, event, helper) {
|
||||||
|
var forgotPwdUrl = cmp.get("v.communityForgotPasswordUrl");
|
||||||
|
if ($A.util.isUndefinedOrNull(forgotPwdUrl)) {
|
||||||
|
forgotPwdUrl = cmp.get("v.forgotPasswordUrl");
|
||||||
|
}
|
||||||
|
var startUrl = cmp.get("v.startUrl");
|
||||||
|
if(startUrl){
|
||||||
|
if(forgotPwdUrl.indexOf("?") === -1) {
|
||||||
|
forgotPwdUrl = forgotPwdUrl + '?startURL=' + decodeURIComponent(startUrl);
|
||||||
|
} else {
|
||||||
|
forgotPwdUrl = forgotPwdUrl + '&startURL=' + decodeURIComponent(startUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var attributes = { url: forgotPwdUrl };
|
||||||
|
$A.get("e.force:navigateToURL").setParams(attributes).fire();
|
||||||
|
},
|
||||||
|
|
||||||
|
navigateToSelfRegister: function(cmp, event, helper) {
|
||||||
|
var selfRegUrl = cmp.get("v.communitySelfRegisterUrl");
|
||||||
|
if (selfRegUrl == null) {
|
||||||
|
selfRegUrl = cmp.get("v.selfRegisterUrl");
|
||||||
|
}
|
||||||
|
var startUrl = cmp.get("v.startUrl");
|
||||||
|
if(startUrl){
|
||||||
|
if(selfRegUrl.indexOf("?") === -1) {
|
||||||
|
selfRegUrl = selfRegUrl + '?startURL=' + decodeURIComponent(startUrl);
|
||||||
|
} else {
|
||||||
|
selfRegUrl = selfRegUrl + '&startURL=' + decodeURIComponent(startUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var attributes = { url: selfRegUrl };
|
||||||
|
$A.get("e.force:navigateToURL").setParams(attributes).fire();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,83 @@
|
||||||
|
({
|
||||||
|
|
||||||
|
qsToEventMap: {
|
||||||
|
'startURL' : 'e.c:setStartUrl'
|
||||||
|
},
|
||||||
|
|
||||||
|
qsToEventMap2: {
|
||||||
|
'expid' : 'e.c:setExpId'
|
||||||
|
},
|
||||||
|
|
||||||
|
handleLogin: function (component, event, helpler) {
|
||||||
|
var username = component.find("username").get("v.value");
|
||||||
|
var password = component.find("password").get("v.value");
|
||||||
|
var action = component.get("c.login");
|
||||||
|
var startUrl = component.get("v.startUrl");
|
||||||
|
|
||||||
|
startUrl = decodeURIComponent(startUrl);
|
||||||
|
|
||||||
|
action.setParams({username:username, password:password, startUrl:startUrl});
|
||||||
|
action.setCallback(this, function(a){
|
||||||
|
var rtnValue = a.getReturnValue();
|
||||||
|
if (rtnValue !== null) {
|
||||||
|
component.set("v.errorMessage",rtnValue);
|
||||||
|
component.set("v.showError",true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
getIsUsernamePasswordEnabled : function (component, event, helpler) {
|
||||||
|
var action = component.get("c.getIsUsernamePasswordEnabled");
|
||||||
|
action.setCallback(this, function(a){
|
||||||
|
var rtnValue = a.getReturnValue();
|
||||||
|
if (rtnValue !== null) {
|
||||||
|
component.set('v.isUsernamePasswordEnabled',rtnValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
getIsSelfRegistrationEnabled : function (component, event, helpler) {
|
||||||
|
var action = component.get("c.getIsSelfRegistrationEnabled");
|
||||||
|
action.setCallback(this, function(a){
|
||||||
|
var rtnValue = a.getReturnValue();
|
||||||
|
if (rtnValue !== null) {
|
||||||
|
component.set('v.isSelfRegistrationEnabled',rtnValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
getCommunityForgotPasswordUrl : function (component, event, helpler) {
|
||||||
|
var action = component.get("c.getForgotPasswordUrl");
|
||||||
|
action.setCallback(this, function(a){
|
||||||
|
var rtnValue = a.getReturnValue();
|
||||||
|
if (rtnValue !== null) {
|
||||||
|
component.set('v.communityForgotPasswordUrl',rtnValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
getCommunitySelfRegisterUrl : function (component, event, helpler) {
|
||||||
|
var action = component.get("c.getSelfRegistrationUrl");
|
||||||
|
action.setCallback(this, function(a){
|
||||||
|
var rtnValue = a.getReturnValue();
|
||||||
|
if (rtnValue !== null) {
|
||||||
|
component.set('v.communitySelfRegisterUrl',rtnValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
setBrandingCookie: function (component, event, helpler) {
|
||||||
|
var expId = component.get("v.expid");
|
||||||
|
if (expId) {
|
||||||
|
var action = component.get("c.setExperienceId");
|
||||||
|
action.setParams({expId:expId});
|
||||||
|
action.setCallback(this, function(a){ });
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
<!-- add implements="forceCommunity:availableForAllPageTypes" to surface the component in community builder -->
|
||||||
|
<aura:component controller="LightningSelfRegisterController">
|
||||||
|
<aura:attribute name="accountId" type="String" required="false" description="accountId for creating the user. If not specified, it will create a PersonAccount if possible for B2C scenario. Or otherwise if it's in a community, the community's self-registration accountId will be used."/>
|
||||||
|
<aura:attribute name="regConfirmUrl" type="String" required="true"/>
|
||||||
|
<aura:attribute name="startUrl" type="String" required="false" description="The url you go to after a successful login" />
|
||||||
|
<aura:attribute name="showError" type="Boolean" required="true" description="" default="false" access="private"/>
|
||||||
|
<aura:attribute name="errorMessage" type="String" required="false" description="" access="private"/>
|
||||||
|
<aura:attribute name="firstnameLabel" type="String" required="false" default="First Name"/>
|
||||||
|
<aura:attribute name="lastnameLabel" type="String" required="false" default="Last Name"/>
|
||||||
|
<aura:attribute name="emailLabel" type="String" required="false" default="Email"/>
|
||||||
|
<aura:attribute name="passwordLabel" type="String" required="false" default="Create Password"/>
|
||||||
|
<aura:attribute name="confirmPasswordLabel" type="String" required="false" default="Confirm Password"/>
|
||||||
|
<aura:attribute name="submitButtonLabel" type="String" required="false" default="Sign Up"/>
|
||||||
|
<aura:attribute name="includePasswordField" type="Boolean" required="false" default="false" description="Whether to include password"/>
|
||||||
|
<aura:attribute name="extraFieldsFieldSet" type="String" required="false" description="A field set name whose fields are desired for user registration"/>
|
||||||
|
<aura:attribute name="extraFields" type="list" required="false" description="A field set name whose fields are desired for user registration"/>
|
||||||
|
<aura:handler name="init" value="{!this}" action="{!c.initialize}"/>
|
||||||
|
<aura:attribute name="expid" type="String" required="false" description="The branding experience ID" />
|
||||||
|
|
||||||
|
<aura:registerevent name="sitePropagatedStartUrl" type="c:setStartUrl"/>
|
||||||
|
<aura:handler name="init" value="{!this}" action="{!c.initialize}"/>
|
||||||
|
<aura:dependency resource="c:setStartUrl" type="EVENT"/>
|
||||||
|
<!-- Please uncomment
|
||||||
|
<aura:dependency resource="siteforce:registerQueryEventMap" type="EVENT"/>
|
||||||
|
-->
|
||||||
|
<aura:handler event="c:setStartUrl" action="{!c.setStartUrl}"/>
|
||||||
|
<aura:handler event="c:setExpId" action="{!c.setExpId}"/>
|
||||||
|
<aura:dependency resource="c:setExpId" type="EVENT"/>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<aura:renderIf isTrue="{!v.showError}">
|
||||||
|
<div id="error">
|
||||||
|
<ui:outputRichText value="{!v.errorMessage}"/>
|
||||||
|
</div>
|
||||||
|
</aura:renderIf>
|
||||||
|
<div id="sfdc_username_container" class="sfdc">
|
||||||
|
<span id="sfdc_user" class="login-icon" data-icon="a"></span>
|
||||||
|
<ui:inputText value="" aura:id="firstname" placeholder="{!v.firstnameLabel}" keyup="{!c.onKeyUp}" class="input sfdc_usernameinput sfdc"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="sfdc_nickname_container" class="sfdc">
|
||||||
|
<span id="sfdc_user" class="login-icon" data-icon="a"></span>
|
||||||
|
<ui:inputText value="" aura:id="lastname" placeholder="{!v.lastnameLabel}" keyup="{!c.onKeyUp}" class="input sfdc_usernameinput sfdc"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="sfdc_email_container" class="sfdc">
|
||||||
|
<span id="sfdc_user" class="login-icon" data-icon="k"></span>
|
||||||
|
<ui:inputText value="" aura:id="email" placeholder="{!v.emailLabel}" keyup="{!c.onKeyUp}" class="input sfdc_usernameinput sfdc"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<aura:iteration aura:id="extraFields" items="{!v.extraFields}" var="curField" indexVar="index">
|
||||||
|
<div id="sfdc_extrafield_container" class="sfdc">
|
||||||
|
<span id="sfdc_user" class="login-icon" data-icon="a"></span>
|
||||||
|
<ui:inputText value="{!curField.value}" aura:id="{!curField.fieldPath}" placeholder="{!curField.label}" keyup="{!c.onKeyUp}" class="input sfdc_extrafieldinput sfdc"/>
|
||||||
|
</div>
|
||||||
|
</aura:iteration>
|
||||||
|
|
||||||
|
<aura:renderIf isTrue="{!v.includePasswordField}">
|
||||||
|
<div id="sfdc_password_container" class="sfdc">
|
||||||
|
<span id="sfdc_lock" class="login-icon sfdc" data-icon="c"></span>
|
||||||
|
<ui:inputSecret value="" aura:id="password" placeholder="{!v.passwordLabel}" keyup="{!c.onKeyUp}" class="input sfdc_passwordinput sfdc"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="sfdc_confirm_password_container" class="sfdc">
|
||||||
|
<span id="sfdc_lock" class="login-icon sfdc" data-icon="c"></span>
|
||||||
|
<ui:inputSecret value="" aura:id="confirmPassword" placeholder="{!v.confirmPasswordLabel}" keyup="{!c.onKeyUp}" class="input sfdc_passwordinput sfdc"/>
|
||||||
|
</div>
|
||||||
|
</aura:renderIf>
|
||||||
|
|
||||||
|
<div class="sfdc">
|
||||||
|
<ui:button aura:id="submitButton" label="{!v.submitButtonLabel}" press="{!c.handleSelfRegister}" class="sfdc_button"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aura:component>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<description>Sample Component for selfRegister</description>
|
||||||
|
</AuraDefinitionBundle>
|
||||||
|
|
@ -0,0 +1,174 @@
|
||||||
|
.THIS #sfdc_username_container{
|
||||||
|
margin-bottom:10px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_nickname_container{
|
||||||
|
margin-bottom:10px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_email_container{
|
||||||
|
margin-bottom:10px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_extrafield_container{
|
||||||
|
margin-bottom:10px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_user{
|
||||||
|
float:left;
|
||||||
|
width:23px;
|
||||||
|
height:25px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-left:2px;
|
||||||
|
margin:0px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_lock{
|
||||||
|
float:left;
|
||||||
|
width:23px;
|
||||||
|
height:25px;
|
||||||
|
padding-top:1px;
|
||||||
|
padding-left:2px;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS .login-icon {
|
||||||
|
color:#ccc;font-size:22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_password_container{
|
||||||
|
margin-bottom:10px;
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_confirm_password_container{
|
||||||
|
padding: 12px;
|
||||||
|
background-color:white;
|
||||||
|
border: 1px solid #CCC;
|
||||||
|
-webkit-border-radius: 2px;
|
||||||
|
-moz-border-radius: 2px;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS button.sfdc_button {
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #0070d2;
|
||||||
|
border-color: #357ebd;
|
||||||
|
display: inline-block;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
background-image: none;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
white-space: nowrap;
|
||||||
|
padding: 10px 12px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: 'Open Sans', sans-serif;
|
||||||
|
font-weight: 300;
|
||||||
|
line-height: 1.42857143;
|
||||||
|
border-radius: 2px;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS button:hover {
|
||||||
|
background-color:#3276b1;
|
||||||
|
border-color:#285e8e;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS input {
|
||||||
|
margin-left:10px;
|
||||||
|
margin-top: 3px;
|
||||||
|
border: 0px solid transparent;
|
||||||
|
width: 70%;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #sfdc_forgot{
|
||||||
|
font-family: 'Open Sans', 'sans-serif';
|
||||||
|
font-weight:300;
|
||||||
|
font-size: 14px;
|
||||||
|
margin-top: 10px
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS #error {
|
||||||
|
text-align: center;
|
||||||
|
color:#FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS a {
|
||||||
|
color:white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.THIS a:hover {
|
||||||
|
color:white;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS input[type="checkbox"] {
|
||||||
|
appearance: none;
|
||||||
|
border: 1px solid white;
|
||||||
|
height: 22px;
|
||||||
|
width: 22px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS input[type="checkbox"]:checked {
|
||||||
|
border: 1px solid ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS input[type="checkbox"]:checked:after {
|
||||||
|
display: block;
|
||||||
|
position: relative;
|
||||||
|
content: '';
|
||||||
|
left: 3px;
|
||||||
|
top: 3px;
|
||||||
|
height: 6px;
|
||||||
|
width: 10px;
|
||||||
|
border-bottom: 4px solid /*#354452*/ white;
|
||||||
|
border-left: 4px solid /*#354452*/ white;
|
||||||
|
transform:rotate(-45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS input[type="checkbox"].disabled {
|
||||||
|
opacity: 0.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
.THIS input[type="checkbox"] + label {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<design:component label="Custom Self Register">
|
||||||
|
<design:attribute name="startUrl"/>
|
||||||
|
<design:attribute name="regConfirmUrl" default="./CheckPasswordResetEmail"/>
|
||||||
|
<design:attribute name="firstnameLabel" default="First Name"/>
|
||||||
|
<design:attribute name="lastnameLabel" default="Last Name"/>
|
||||||
|
<design:attribute name="emailLabel" default="Email"/>
|
||||||
|
<design:attribute name="passwordLabel" default="Create Password"/>
|
||||||
|
<design:attribute name="confirmPasswordLabel" default="Confirm Password"/>
|
||||||
|
<design:attribute name="submitButtonLabel" default="Sign Up"/>
|
||||||
|
<design:attribute name="includePasswordField" default="false"/>
|
||||||
|
<design:attribute name="extraFieldsFieldSet"/>
|
||||||
|
</design:component>
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
({
|
||||||
|
initialize: function(component, event, helper) {
|
||||||
|
$A.get("e.siteforce:registerQueryEventMap").setParams({"qsToEvent" : helper.qsToEventMap}).fire();
|
||||||
|
$A.get("e.siteforce:registerQueryEventMap").setParams({"qsToEvent" : helper.qsToEventMap2}).fire();
|
||||||
|
component.set('v.extraFields', helper.getExtraFields(component, event, helper));
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSelfRegister: function (component, event, helpler) {
|
||||||
|
helpler.handleSelfRegister(component, event, helpler);
|
||||||
|
},
|
||||||
|
|
||||||
|
setStartUrl: function (component, event, helpler) {
|
||||||
|
var startUrl = event.getParam('startURL');
|
||||||
|
if(startUrl) {
|
||||||
|
component.set("v.startUrl", startUrl);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setExpId: function (component, event, helper) {
|
||||||
|
var expId = event.getParam('expid');
|
||||||
|
if (expId) {
|
||||||
|
component.set("v.expid", expId);
|
||||||
|
}
|
||||||
|
helper.setBrandingCookie(component, event, helper);
|
||||||
|
},
|
||||||
|
|
||||||
|
onKeyUp: function(component, event, helpler){
|
||||||
|
//checks for "enter" key
|
||||||
|
if (event.getParam('keyCode')===13) {
|
||||||
|
helpler.handleSelfRegister(component, event, helpler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
({
|
||||||
|
qsToEventMap: {
|
||||||
|
'startURL' : 'e.c:setStartUrl'
|
||||||
|
},
|
||||||
|
|
||||||
|
qsToEventMap2: {
|
||||||
|
'expid' : 'e.c:setExpId'
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSelfRegister: function (component, event, helpler) {
|
||||||
|
var accountId = component.get("v.accountId");
|
||||||
|
var regConfirmUrl = component.get("v.regConfirmUrl");
|
||||||
|
var firstname = component.find("firstname").get("v.value");
|
||||||
|
var lastname = component.find("lastname").get("v.value");
|
||||||
|
var email = component.find("email").get("v.value");
|
||||||
|
var includePassword = component.get("v.includePasswordField");
|
||||||
|
var password = component.find("password").get("v.value");
|
||||||
|
var confirmPassword = component.find("confirmPassword").get("v.value");
|
||||||
|
var action = component.get("c.selfRegister");
|
||||||
|
var extraFields = JSON.stringify(component.get("v.extraFields")); // somehow apex controllers refuse to deal with list of maps
|
||||||
|
var startUrl = component.get("v.startUrl");
|
||||||
|
|
||||||
|
startUrl = decodeURIComponent(startUrl);
|
||||||
|
|
||||||
|
action.setParams({firstname:firstname,lastname:lastname,email:email,
|
||||||
|
password:password, confirmPassword:confirmPassword, accountId:accountId, regConfirmUrl:regConfirmUrl, extraFields:extraFields, startUrl:startUrl, includePassword:includePassword});
|
||||||
|
action.setCallback(this, function(a){
|
||||||
|
var rtnValue = a.getReturnValue();
|
||||||
|
if (rtnValue !== null) {
|
||||||
|
component.set("v.errorMessage",rtnValue);
|
||||||
|
component.set("v.showError",true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
getExtraFields : function (component, event, helpler) {
|
||||||
|
var action = component.get("c.getExtraFields");
|
||||||
|
action.setParam("extraFieldsFieldSet", component.get("v.extraFieldsFieldSet"));
|
||||||
|
action.setCallback(this, function(a){
|
||||||
|
var rtnValue = a.getReturnValue();
|
||||||
|
if (rtnValue !== null) {
|
||||||
|
component.set('v.extraFields',rtnValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
},
|
||||||
|
|
||||||
|
setBrandingCookie: function (component, event, helpler) {
|
||||||
|
var expId = component.get("v.expid");
|
||||||
|
if (expId) {
|
||||||
|
var action = component.get("c.setExperienceId");
|
||||||
|
action.setParams({expId:expId});
|
||||||
|
action.setCallback(this, function(a){ });
|
||||||
|
$A.enqueueAction(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<aura:event type="APPLICATION">
|
||||||
|
<aura:attribute name="expid" type="String"/>
|
||||||
|
</aura:event>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<description>Sample Event for setExpId</description>
|
||||||
|
</AuraDefinitionBundle>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<aura:event type="APPLICATION">
|
||||||
|
<aura:attribute name="startURL" type="Map"/>
|
||||||
|
</aura:event>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<AuraDefinitionBundle xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<description>Sample Event for setStartUrl</description>
|
||||||
|
</AuraDefinitionBundle>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
public with sharing class AccountController {
|
||||||
|
@AuraEnabled(cacheable=true)
|
||||||
|
public static List<Account> findAccounts(String searchKey) {
|
||||||
|
String key = searchKey + '%';
|
||||||
|
return [SELECT Id, Name FROM Account WHERE Name LIKE :key LIMIT 5];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
public with sharing class AccountHelper {
|
||||||
|
@AuraEnabled(cacheable=true)
|
||||||
|
public Static List<Account> getAccount() {
|
||||||
|
return[SELECT Name,Phone FROM Account LIMIT 10];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>57.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
// AccountRelatedListController.apxc
|
||||||
|
public with sharing class AccountRelatedListController {
|
||||||
|
@AuraEnabled(cacheable=true)
|
||||||
|
public static List<Contact> getAccountContacts(Id accountId) {
|
||||||
|
return [
|
||||||
|
SELECT Id, Name, Email, Phone
|
||||||
|
FROM Contact
|
||||||
|
WHERE AccountId = :accountId
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuraEnabled(cacheable=true)
|
||||||
|
public static List<Opportunity> getAccountOpportunities(Id accountId) {
|
||||||
|
return [
|
||||||
|
SELECT Id, Name, StageName, Amount
|
||||||
|
FROM Opportunity
|
||||||
|
WHERE AccountId = :accountId
|
||||||
|
];
|
||||||
|
}
|
||||||
|
@AuraEnabled
|
||||||
|
public static void updateFileds(List <SObject> recordInput) {
|
||||||
|
System.debug('recordInput ' + recordInput);
|
||||||
|
|
||||||
|
try {
|
||||||
|
update recordInput;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AuraHandledException('Could not update records: ' + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
public with sharing class AccountSearchController {
|
||||||
|
@AuraEnabled(cacheable=true)
|
||||||
|
public static List<Account> searchAccounts(String searchValue) {
|
||||||
|
List<Account> accounts = new List<Account>();
|
||||||
|
if (String.isNotBlank(searchValue)) {
|
||||||
|
String searchQuery = searchValue + '%';
|
||||||
|
accounts = [SELECT Id, Name,Type,Phone,ShippingStreet,ShippingCity,ShippingState,ShippingPostalCode FROM Account WHERE Name LIKE :searchQuery ORDER BY Name ASC];
|
||||||
|
}
|
||||||
|
System.debug('Accounts: ' + accounts);
|
||||||
|
return accounts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
@isTest
|
||||||
|
public class AccountSearchControllerTest {
|
||||||
|
@isTest static void testSearchAccounts() {
|
||||||
|
// Prepare test data
|
||||||
|
Account testAccount1 = new Account(Name = 'Test Account 1');
|
||||||
|
Account testAccount2 = new Account(Name = 'Test Account 2');
|
||||||
|
insert new List<Account>{ testAccount1, testAccount2 };
|
||||||
|
|
||||||
|
// Call the method to test
|
||||||
|
Test.startTest();
|
||||||
|
List<Account> accounts = AccountSearchController.searchAccounts('Test');
|
||||||
|
Test.stopTest();
|
||||||
|
|
||||||
|
// Verify the results
|
||||||
|
System.assertEquals(2, accounts.size(), 'Expected to find 2 accounts');
|
||||||
|
System.assertEquals(testAccount1.Id, accounts[0].Id, 'The first account ID does not match');
|
||||||
|
System.assertEquals(testAccount2.Id, accounts[1].Id, 'The second account ID does not match');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**
|
||||||
|
* This class handles the addition of attachments to projects.
|
||||||
|
*/
|
||||||
|
public with sharing class AddAttachementToProjectHandler {
|
||||||
|
//Method to add attachments to a list of projects.
|
||||||
|
public static void AddAttachments(List<ProjectDemo__c> newProject) {
|
||||||
|
// Collect the Opportunity IDs associated with the new projects
|
||||||
|
try{
|
||||||
|
Set<Id> oppIds = new Set<Id>();
|
||||||
|
|
||||||
|
for (ProjectDemo__c pro : newProject) {
|
||||||
|
oppIds.add(pro.Opportunity_Name__c);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Retrieve ContentDocumentLink records for the collected Opportunity IDs
|
||||||
|
List<ContentDocumentLink> contentDocumentLinks = [
|
||||||
|
SELECT ContentDocumentId, LinkedEntityId, ShareType, Visibility
|
||||||
|
FROM ContentDocumentLink
|
||||||
|
WHERE LinkedEntityId IN :oppIds
|
||||||
|
];
|
||||||
|
|
||||||
|
// Organize ContentDocumentLinks by Opportunity ID
|
||||||
|
Map<Id, List<ContentDocumentLink>> projectIdToContentDocumentLinks = new Map<Id, List<ContentDocumentLink>>();
|
||||||
|
for (ContentDocumentLink cdl : contentDocumentLinks) {
|
||||||
|
List<ContentDocumentLink> cdlList = projectIdToContentDocumentLinks.containsKey(cdl.LinkedEntityId) ?
|
||||||
|
projectIdToContentDocumentLinks.get(cdl.LinkedEntityId) :
|
||||||
|
new List<ContentDocumentLink>();
|
||||||
|
cdlList.add(cdl);
|
||||||
|
projectIdToContentDocumentLinks.put(cdl.LinkedEntityId, cdlList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare a list of ContentDocumentLinks to be inserted
|
||||||
|
List<ContentDocumentLink> insertCdlList = new List<ContentDocumentLink>();
|
||||||
|
for (ProjectDemo__c proj : newProject) {
|
||||||
|
system.debug('@@@@@@ proid:'+proj.Id);
|
||||||
|
if (projectIdToContentDocumentLinks.containsKey(proj.Opportunity_Name__c)) {
|
||||||
|
List<ContentDocumentLink> contentDocumentLinksToCopy = projectIdToContentDocumentLinks.get(proj.Opportunity_Name__c);
|
||||||
|
for (ContentDocumentLink cdl : contentDocumentLinksToCopy) {
|
||||||
|
// Create new ContentDocumentLink records with relevant data
|
||||||
|
ContentDocumentLink newCdl = new ContentDocumentLink(
|
||||||
|
ContentDocumentId = cdl.ContentDocumentId,
|
||||||
|
LinkedEntityId = proj.Id,
|
||||||
|
ShareType = cdl.ShareType,
|
||||||
|
Visibility = cdl.Visibility
|
||||||
|
);
|
||||||
|
insertCdlList.add(newCdl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the new ContentDocumentLink records if the list is not empty
|
||||||
|
if (!insertCdlList.isEmpty()) {
|
||||||
|
database.insert(insertCdlList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(exception ex){
|
||||||
|
system.debug('Error Occur ==' +ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
@isTest
|
||||||
|
public class AddAttachmentToProjectTest {
|
||||||
|
@isTest static void testAddAttachments() {
|
||||||
|
// Created test data
|
||||||
|
Opportunity opp = new Opportunity(Name = 'New Opp', StageName = 'Prospecting', CloseDate = Date.today());
|
||||||
|
insert opp;
|
||||||
|
|
||||||
|
ProjectDemo__c proj = new ProjectDemo__c(Opportunity_Name__c = opp.Id);
|
||||||
|
insert proj;
|
||||||
|
|
||||||
|
ContentVersion cv = new ContentVersion(
|
||||||
|
Title = 'New Content version',
|
||||||
|
PathOnClient = 'Test.txt',
|
||||||
|
VersionData = Blob.valueOf('Test Content')
|
||||||
|
);
|
||||||
|
insert cv;
|
||||||
|
|
||||||
|
Id cdId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id].ContentDocumentId;
|
||||||
|
|
||||||
|
ContentDocumentLink cdl = new ContentDocumentLink(
|
||||||
|
ContentDocumentId = cdId,
|
||||||
|
LinkedEntityId = opp.Id,
|
||||||
|
ShareType = 'V',
|
||||||
|
Visibility = 'AllUsers'
|
||||||
|
);
|
||||||
|
insert cdl;
|
||||||
|
|
||||||
|
// Calling the method to test
|
||||||
|
Test.startTest();
|
||||||
|
AddAttachementToProjectHandler.AddAttachments(new List<ProjectDemo__c>{proj});
|
||||||
|
Test.stopTest();
|
||||||
|
|
||||||
|
// Verifing the results
|
||||||
|
List<ContentDocumentLink> resultCdlList = [SELECT Id FROM ContentDocumentLink WHERE LinkedEntityId = :proj.Id];
|
||||||
|
System.assertEquals(1, resultCdlList.size());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
public with sharing class ApexController {
|
||||||
|
@AuraEnabled(cacheable=true)
|
||||||
|
public static List<Contact> findMethod(String paramOne) {
|
||||||
|
// SOQL query here
|
||||||
|
List<Contact> records = [SELECT Id, Name FROM Contact WHERE LastName = :paramOne LIMIT 1];
|
||||||
|
return records;
|
||||||
|
}
|
||||||
|
|
||||||
|
@AuraEnabled
|
||||||
|
public static String changeMethod(String paramForChangeOne) {
|
||||||
|
// DML operation here
|
||||||
|
Contact record = [SELECT Id, ChangedName__c FROM Contact WHERE LastName = :paramForChangeOne LIMIT 1];
|
||||||
|
record.ChangedName__c = paramForChangeOne;
|
||||||
|
update record;
|
||||||
|
return 'Record updated successfully';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
@isTest
|
||||||
|
public class AssignTest {
|
||||||
|
@isTest static void testMthd(){
|
||||||
|
|
||||||
|
List<Opportunity>oppl=new List<Opportunity>();
|
||||||
|
Opportunity op=new Opportunity();
|
||||||
|
op.CloseDate=Date.today();
|
||||||
|
op.Name='Yumi';
|
||||||
|
|
||||||
|
op.StageName='Closed Won';
|
||||||
|
oppl.add(op);
|
||||||
|
insert oppl;
|
||||||
|
|
||||||
|
List<Task> tasksToInsert = new List<Task>();
|
||||||
|
for (Opportunity opps :oppl) {
|
||||||
|
if (opps.StageName == 'Closed Won') {
|
||||||
|
Task newTask = new Task();
|
||||||
|
newTask.Subject = 'Opportunity Closed Won ho gyi hai bhai';
|
||||||
|
newTask.Description = 'Account Name: ' + opps.Account.Name + '\nOpportunity Name: ' + opps.Name + '\nClose Date: ' + opps.CloseDate;
|
||||||
|
tasksToInsert.add(newTask);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tasksToInsert.isEmpty()) {
|
||||||
|
insert tasksToInsert;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,171 @@
|
||||||
|
public class BrevoContactTrigger_Handler {
|
||||||
|
/*Method to create contact in Brevo when created in SF*/
|
||||||
|
|
||||||
|
@future(callout=true)
|
||||||
|
public static void createContactInBrevo(String email, String firstName, String lastName, String phone, Id contactId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Fetch the contact record
|
||||||
|
Contact con = [SELECT Brevo_Status__c, Brevo_List__c FROM Contact WHERE Id = :contactId];
|
||||||
|
|
||||||
|
// Map the Brevo_List__c values to list IDs
|
||||||
|
Map<String, Integer> listMap = new Map<String, Integer>{
|
||||||
|
'Salesforce Contact'=> 7,
|
||||||
|
'Test List' => 8,
|
||||||
|
'Identified Contacts' => 6
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get the list IDs from the Brevo_List__c field
|
||||||
|
List<Integer> listIds = new List<Integer>();
|
||||||
|
for (String listName : con.Brevo_List__c.split(';')) {
|
||||||
|
if (listMap.containsKey(listName)) {
|
||||||
|
listIds.add(listMap.get(listName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HttpRequest req = new HttpRequest();
|
||||||
|
Http http = new Http();
|
||||||
|
|
||||||
|
req.setEndpoint('https://api.brevo.com/v3/contacts');
|
||||||
|
req.setMethod('POST');
|
||||||
|
req.setHeader('Content-Type', 'application/json');
|
||||||
|
req.setHeader('api-key', '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');
|
||||||
|
Map<String, Object> brevoContact = new Map<String, Object>();
|
||||||
|
brevoContact.put('email', email);
|
||||||
|
Map<String, Object> brevoAttributes = new Map<String, Object>();
|
||||||
|
brevoAttributes.put('FIRSTNAME', firstName);
|
||||||
|
brevoAttributes.put('LASTNAME', lastName);
|
||||||
|
brevoAttributes.put('SMS', phone);
|
||||||
|
brevoContact.put('attributes', brevoAttributes);
|
||||||
|
String brevoBody = JSON.serialize(brevoContact);
|
||||||
|
req.setBody(brevoBody);
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpResponse res = http.send(req);
|
||||||
|
if (res.getStatusCode() != 201) {
|
||||||
|
System.debug('Failed to create contact in Brevo with status code: ' + res.getStatusCode());
|
||||||
|
con.Brevo_Status__c = 'Error: ' + res.getStatusCode();
|
||||||
|
}else{
|
||||||
|
Map<String, Object> responseMap = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
|
||||||
|
String brevoId = String.valueOf(responseMap.get('id'));
|
||||||
|
//String successMessage = String.valueOf(responseMap.get('message'));
|
||||||
|
System.debug('Created Successfully in Brevo with ID: '+ brevoId);
|
||||||
|
con.Brevo_Status__c = 'Contact created in Brevo successfully: ' + ', Brevo ID: ' + brevoId;
|
||||||
|
}
|
||||||
|
database.update(con);
|
||||||
|
} catch(Exception ex) {
|
||||||
|
System.debug('API call failed with message: ' + ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception ex) {
|
||||||
|
System.debug('API call failed with message: ' + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Method to update contact in Brevo when updated in SF Also, if update contact not exist in Brevo create new one*/
|
||||||
|
|
||||||
|
@future(callout=true)
|
||||||
|
public static void updateContactInBrevo(String email, String firstName, String lastName, String phone, Id contactId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpRequest req = new HttpRequest();
|
||||||
|
Http http = new Http();
|
||||||
|
|
||||||
|
// GET request to check if the contact exists
|
||||||
|
req.setEndpoint('https://api.brevo.com/v3/contacts/' + email);
|
||||||
|
req.setMethod('GET');
|
||||||
|
req.setHeader('Content-Type', 'application/json');
|
||||||
|
req.setHeader('api-key', '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');
|
||||||
|
|
||||||
|
HttpResponse res = http.send(req);
|
||||||
|
Contact con = [SELECT Brevo_Status__c FROM Contact WHERE Id = :contactId];
|
||||||
|
if (res.getStatusCode() == 200) {
|
||||||
|
// contact exists, sending a PUT request to update the contact
|
||||||
|
req.setMethod('PUT');
|
||||||
|
Map<String, Object> brevoContact = new Map<String, Object>();
|
||||||
|
brevoContact.put('email', email);
|
||||||
|
Map<String, Object> brevoAttributes = new Map<String, Object>();
|
||||||
|
brevoAttributes.put('FIRSTNAME', firstName);
|
||||||
|
brevoAttributes.put('LASTNAME', lastName);
|
||||||
|
brevoAttributes.put('SMS', phone);
|
||||||
|
brevoContact.put('attributes', brevoAttributes);
|
||||||
|
String brevoBody = JSON.serialize(brevoContact);
|
||||||
|
req.setBody(brevoBody);
|
||||||
|
|
||||||
|
HttpResponse updateRes = http.send(req);
|
||||||
|
if (updateRes.getStatusCode() == 204) {
|
||||||
|
System.debug('Record successfully updated in Brevo with status code: ' + updateRes.getStatusCode());
|
||||||
|
con.Brevo_Status__c = 'Update Successfully, Brevo Email: ' + email;
|
||||||
|
} else {
|
||||||
|
System.debug('Failed to update contact in Brevo with status code: ' + updateRes.getStatusCode());
|
||||||
|
con.Brevo_Status__c = 'Update Error: ' + updateRes.getStatusCode();
|
||||||
|
}
|
||||||
|
database.update(con);
|
||||||
|
} else {
|
||||||
|
System.debug('Contact does not exist in Brevo creating new');
|
||||||
|
HttpRequest req1 = new HttpRequest();
|
||||||
|
Http http1 = new Http();
|
||||||
|
|
||||||
|
req1.setEndpoint('https://api.brevo.com/v3/contacts');
|
||||||
|
req1.setMethod('POST');
|
||||||
|
req1.setHeader('Content-Type', 'application/json');
|
||||||
|
req1.setHeader('api-key', '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');
|
||||||
|
Map<String, Object> brevoContact = new Map<String, Object>();
|
||||||
|
brevoContact.put('email', email);
|
||||||
|
Map<String, Object> brevoAttributes = new Map<String, Object>();
|
||||||
|
brevoAttributes.put('FIRSTNAME', firstName);
|
||||||
|
brevoAttributes.put('LASTNAME', lastName);
|
||||||
|
brevoAttributes.put('SMS', phone);
|
||||||
|
brevoContact.put('attributes', brevoAttributes);
|
||||||
|
String brevoBody = JSON.serialize(brevoContact);
|
||||||
|
req1.setBody(brevoBody);
|
||||||
|
|
||||||
|
HttpResponse res1 = http.send(req1);
|
||||||
|
if (res1.getStatusCode() != 201) {
|
||||||
|
System.debug('Failed to create contact in Brevo with status code: ' + res.getStatusCode());
|
||||||
|
con.Brevo_Status__c = 'Create Error: ' + res.getStatusCode();
|
||||||
|
}else{
|
||||||
|
Map<String, Object> responseMap = (Map<String, Object>) JSON.deserializeUntyped(res1.getBody());
|
||||||
|
String brevoId = String.valueOf(responseMap.get('id'));
|
||||||
|
System.debug('Created Successfully in Brevo with ID: '+ brevoId);
|
||||||
|
con.Brevo_Status__c = 'Create Success, Brevo ID: ' + brevoId;
|
||||||
|
}
|
||||||
|
database.update(con);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Exception ex) {
|
||||||
|
System.debug('API call failed with message: ' + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*Method to delete contact from Brevo when deleted from SF*/
|
||||||
|
|
||||||
|
@future(callout=true)
|
||||||
|
public static void deleteContactInBrevo(String email) {
|
||||||
|
HttpRequest req = new HttpRequest();
|
||||||
|
Http http = new Http();
|
||||||
|
|
||||||
|
// GET request to check if the contact exists
|
||||||
|
req.setEndpoint('https://api.brevo.com/v3/contacts/' + email);
|
||||||
|
req.setMethod('GET');
|
||||||
|
req.setHeader('Content-Type', 'application/json');
|
||||||
|
req.setHeader('api-key', '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');
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpResponse res = http.send(req);
|
||||||
|
if (res.getStatusCode() == 200) {
|
||||||
|
// contact exists, sending a DELETE request to delete the contact
|
||||||
|
req.setMethod('DELETE');
|
||||||
|
HttpResponse deleteRes = http.send(req);
|
||||||
|
if (deleteRes.getStatusCode() == 204) {
|
||||||
|
System.debug('Record successfully deleted from Brevo with status code: ' + deleteRes.getStatusCode());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.debug('Failed to delete contact in Brevo with status code: ' + deleteRes.getStatusCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(Exception ex) {
|
||||||
|
System.debug('API call failed with message: ' + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
public class BrevoHandler {
|
||||||
|
|
||||||
|
static Map<String, Object> results = new Map<String, Object>();
|
||||||
|
public static void getcontacts(){
|
||||||
|
HttpRequest req = new HttpRequest();
|
||||||
|
Http http = new Http();
|
||||||
|
|
||||||
|
// GET request to check if the contact exists
|
||||||
|
|
||||||
|
req.setEndpoint('https://api.brevo.com/v3/contacts/' );
|
||||||
|
req.setMethod('GET');
|
||||||
|
req.setHeader('Content-Type', 'application/json');
|
||||||
|
req.setHeader('api-key', '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');
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpResponse res = http.send(req);
|
||||||
|
if (res.getStatusCode() == 200) {
|
||||||
|
System.debug('Contact Already Exist in Brevo');
|
||||||
|
results.putAll((Map<String, Object>) JSON.deserializeUntyped(res.getBody()));
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.debug('API call failed with message: ' + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void print(){
|
||||||
|
BrevoHandler.getcontacts();
|
||||||
|
System.debug('@@@@@@@'+results.Size());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createcontact(string email,string firstname,string lastname,string phone){
|
||||||
|
|
||||||
|
Brevohandler.getcontacts();
|
||||||
|
HttpRequest req = new HttpRequest();
|
||||||
|
Http http = new Http();
|
||||||
|
|
||||||
|
req.setEndpoint('https://api.brevo.com/v3/contacts');
|
||||||
|
req.setMethod('POST');
|
||||||
|
req.setHeader('Content-Type', 'application/json');
|
||||||
|
req.setHeader('api-key', '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');
|
||||||
|
Map<String, Object> brevoContact = new Map<String, Object>();
|
||||||
|
brevoContact.put('email', email);
|
||||||
|
Map<String, Object> brevoAttributes = new Map<String, Object>();
|
||||||
|
brevoAttributes.put('FIRSTNAME', firstName);
|
||||||
|
brevoAttributes.put('LASTNAME', lastName);
|
||||||
|
brevoAttributes.put('SMS', phone);
|
||||||
|
brevoContact.put('attributes', brevoAttributes);
|
||||||
|
String brevoBody = JSON.serialize(brevoContact);
|
||||||
|
req.setBody(brevoBody);
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpResponse res = http.send(req);
|
||||||
|
if (res.getStatusCode() != 201) {
|
||||||
|
System.debug('Failed to create contact in Brevo with status code: ' + res.getStatusCode());
|
||||||
|
}else{
|
||||||
|
System.debug('Created Secussfully:'+brevobody);
|
||||||
|
}
|
||||||
|
} catch(Exception e) {
|
||||||
|
System.debug('API call failed with message: ' + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Implement mock callout class
|
||||||
|
@isTest
|
||||||
|
global class BrevoMockHttpResponseGenerator implements HttpCalloutMock {
|
||||||
|
// Implement this interface method
|
||||||
|
global HTTPResponse respond(HTTPRequest req) {
|
||||||
|
// Create a fake response
|
||||||
|
HttpResponse res = new HttpResponse();
|
||||||
|
res.setHeader('Content-Type', 'application/json');
|
||||||
|
if (req.getMethod() == 'GET') {
|
||||||
|
if (req.getEndpoint().contains('test@example.com')) {
|
||||||
|
res.setBody('{"email":"test@example.com"}'); // Set the body as per your requirement for GET
|
||||||
|
res.setStatusCode(200);
|
||||||
|
} else if (req.getEndpoint().contains('test2@example.com')) {
|
||||||
|
res.setBody('{"error":"Contact not found"}'); // Set the body as per your requirement for GET
|
||||||
|
res.setStatusCode(404);
|
||||||
|
}
|
||||||
|
} else if (req.getMethod() == 'PUT') {
|
||||||
|
res.setBody('{"id":"123"}'); // Set the body as per your requirement for PUT
|
||||||
|
res.setStatusCode(204);
|
||||||
|
} else if (req.getMethod() == 'POST') {
|
||||||
|
res.setBody('{"id":"123"}'); // Set the body as per your requirement for POST
|
||||||
|
res.setStatusCode(201);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
global class CallingFromTrigger implements DataBase.Batchable<sObject>{
|
||||||
|
List<Contact>contlist=new List<Contact>();
|
||||||
|
global CallingFromTrigger(List<Contact>clist){
|
||||||
|
contlist=clist;
|
||||||
|
}
|
||||||
|
global DataBase.QueryLocator start(Database.BatchableContext BC){
|
||||||
|
return(DataBase.getQueryLocator([SELECT Id,Email FROM Contact WHERE Id IN:contlist]));
|
||||||
|
|
||||||
|
}
|
||||||
|
global void execute(Database.BatchableContext BC,List<Contact>Scope){
|
||||||
|
for(Contact c:Scope){
|
||||||
|
c.Description='if Email available then we have sent email';
|
||||||
|
|
||||||
|
}
|
||||||
|
Database.update(Scope);
|
||||||
|
}
|
||||||
|
global void finish(Database.BatchableContext BC){
|
||||||
|
for(Contact c:contlist){
|
||||||
|
if(c.Email!=null){
|
||||||
|
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
|
||||||
|
mail.setToAddresses(new String[] {c.Email});
|
||||||
|
mail.setSubject('Added in Contact');
|
||||||
|
String messageBody = 'Hii you are added in contact';
|
||||||
|
mail.setPlainTextBody(messageBody);
|
||||||
|
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
public class CallingbatchClass{
|
||||||
|
public static void CallingbatchMethod(List<Contact>clist){
|
||||||
|
for(Contact c:clist){
|
||||||
|
if(c.Email!=null){
|
||||||
|
Database.executeBatch(new CallingFromTrigger(clist));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that exposes the change password functionality
|
||||||
|
*/
|
||||||
|
public with sharing class ChangePasswordController {
|
||||||
|
public String oldPassword {get; set;}
|
||||||
|
public String newPassword {get; set;}
|
||||||
|
public String verifyNewPassword {get; set;}
|
||||||
|
|
||||||
|
public PageReference changePassword() {
|
||||||
|
return Site.changePassword(newPassword, verifyNewPassword, oldpassword);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChangePasswordController() {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that exposes the change password functionality
|
||||||
|
*/
|
||||||
|
@IsTest public with sharing class ChangePasswordControllerTest {
|
||||||
|
@IsTest(SeeAllData=true) public static void testChangePasswordController() {
|
||||||
|
// Instantiate a new controller with all parameters in the page
|
||||||
|
ChangePasswordController controller = new ChangePasswordController();
|
||||||
|
controller.oldPassword = '123456';
|
||||||
|
controller.newPassword = 'qwerty1';
|
||||||
|
controller.verifyNewPassword = 'qwerty1';
|
||||||
|
|
||||||
|
System.assertEquals(controller.changePassword(),null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
|
||||||
|
*/
|
||||||
|
public with sharing class CommunitiesLandingController {
|
||||||
|
|
||||||
|
// Code we will invoke on page load.
|
||||||
|
public PageReference forwardToStartPage() {
|
||||||
|
return Network.communitiesLanding();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommunitiesLandingController() {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
|
||||||
|
*/
|
||||||
|
@IsTest public with sharing class CommunitiesLandingControllerTest {
|
||||||
|
@IsTest(SeeAllData=true) public static void testCommunitiesLandingController() {
|
||||||
|
// Instantiate a new controller with all parameters in the page
|
||||||
|
CommunitiesLandingController controller = new CommunitiesLandingController();
|
||||||
|
PageReference pageRef = controller.forwardToStartPage();
|
||||||
|
//PageRef is either null or an empty object in test context
|
||||||
|
if(pageRef != null){
|
||||||
|
String url = pageRef.getUrl();
|
||||||
|
if(url != null){
|
||||||
|
System.assertEquals(true, String.isEmpty(url));
|
||||||
|
//show up in perforce
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that exposes the site login functionality
|
||||||
|
*/
|
||||||
|
global with sharing class CommunitiesLoginController {
|
||||||
|
|
||||||
|
global CommunitiesLoginController () {}
|
||||||
|
|
||||||
|
// Code we will invoke on page load.
|
||||||
|
global PageReference forwardToAuthPage() {
|
||||||
|
String startUrl = System.currentPageReference().getParameters().get('startURL');
|
||||||
|
String displayType = System.currentPageReference().getParameters().get('display');
|
||||||
|
return Network.forwardToAuthPage(startUrl, displayType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that exposes the site login functionality
|
||||||
|
*/
|
||||||
|
@IsTest global with sharing class CommunitiesLoginControllerTest {
|
||||||
|
@IsTest(SeeAllData=true)
|
||||||
|
global static void testCommunitiesLoginController () {
|
||||||
|
CommunitiesLoginController controller = new CommunitiesLoginController();
|
||||||
|
System.assertEquals(null, controller.forwardToAuthPage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
|
||||||
|
*/
|
||||||
|
public with sharing class CommunitiesSelfRegConfirmController {
|
||||||
|
|
||||||
|
public CommunitiesSelfRegConfirmController() {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that takes the user to the right start page based on credentials or lack thereof
|
||||||
|
*/
|
||||||
|
@IsTest public with sharing class CommunitiesSelfRegConfirmControllerTest {
|
||||||
|
@IsTest(SeeAllData=true) public static void testCommunitiesSelfRegConfirmController() {
|
||||||
|
// Instantiate a new controller with all parameters in the page
|
||||||
|
CommunitiesSelfRegConfirmController controller = new CommunitiesSelfRegConfirmController();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that supports self registration of users in communities that allow self registration
|
||||||
|
*/
|
||||||
|
public class CommunitiesSelfRegController {
|
||||||
|
|
||||||
|
public String firstName {get; set;}
|
||||||
|
public String lastName {get; set;}
|
||||||
|
public String email {get; set;}
|
||||||
|
public String password {get; set {password = value == null ? value : value.trim(); } }
|
||||||
|
public String confirmPassword {get; set { confirmPassword = value == null ? value : value.trim(); } }
|
||||||
|
public String communityNickname {get; set { communityNickname = value == null ? value : value.trim(); } }
|
||||||
|
|
||||||
|
public CommunitiesSelfRegController() {
|
||||||
|
String expid = ApexPages.currentPage().getParameters().get('expid');
|
||||||
|
if (expId != null) {
|
||||||
|
Site.setExperienceId(expId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidPassword() {
|
||||||
|
return password == confirmPassword;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PageReference registerUser() {
|
||||||
|
|
||||||
|
// it's okay if password is null - we'll send the user a random password in that case
|
||||||
|
if (!isValidPassword()) {
|
||||||
|
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, Label.site.passwords_dont_match);
|
||||||
|
ApexPages.addMessage(msg);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String profileId = null; // To be filled in by customer.
|
||||||
|
String roleEnum = null; // To be filled in by customer.
|
||||||
|
String accountId = ''; // To be filled in by customer.
|
||||||
|
|
||||||
|
String userName = email;
|
||||||
|
|
||||||
|
User u = new User();
|
||||||
|
u.Username = userName;
|
||||||
|
u.Email = email;
|
||||||
|
u.FirstName = firstName;
|
||||||
|
u.LastName = lastName;
|
||||||
|
u.CommunityNickname = communityNickname;
|
||||||
|
u.ProfileId = profileId;
|
||||||
|
|
||||||
|
String userId;
|
||||||
|
|
||||||
|
try {
|
||||||
|
userId = Site.createExternalUser(u, accountId, password);
|
||||||
|
} catch(Site.ExternalUserCreateException ex) {
|
||||||
|
List<String> errors = ex.getDisplayMessages();
|
||||||
|
for (String error : errors) {
|
||||||
|
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, error));
|
||||||
|
}
|
||||||
|
|
||||||
|
// This message is used for debugging. Do not display this in the UI to the end user.
|
||||||
|
// It has the information around why the user creation failed.
|
||||||
|
System.debug(ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userId != null) {
|
||||||
|
if (password != null && password.length() > 1) {
|
||||||
|
return Site.login(userName, password, ApexPages.currentPage().getParameters().get('startURL'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PageReference page = System.Page.CommunitiesSelfRegConfirm;
|
||||||
|
page.setRedirect(true);
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
/**
|
||||||
|
* An apex page controller that supports self registration of users in communities that allow self registration
|
||||||
|
*/
|
||||||
|
@IsTest public with sharing class CommunitiesSelfRegControllerTest {
|
||||||
|
@IsTest(SeeAllData=true)
|
||||||
|
public static void testCommunitiesSelfRegController() {
|
||||||
|
CommunitiesSelfRegController controller = new CommunitiesSelfRegController();
|
||||||
|
controller.firstName = 'FirstName';
|
||||||
|
controller.lastName = 'LastName';
|
||||||
|
controller.email = 'test@force.com';
|
||||||
|
controller.communityNickname = 'test';
|
||||||
|
|
||||||
|
// registerUser will always return null when the page isn't accessed as a guest user
|
||||||
|
System.assert(controller.registerUser() == null);
|
||||||
|
|
||||||
|
controller.password = 'abcd1234';
|
||||||
|
controller.confirmPassword = 'abcd123';
|
||||||
|
System.assert(controller.registerUser() == null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
public without sharing class ContactCreator {
|
||||||
|
@AuraEnabled
|
||||||
|
public static void createContact(String fname, String lname, String email) {
|
||||||
|
System.debug('Creating contact with email: ' + email);
|
||||||
|
|
||||||
|
// Check for duplicate email
|
||||||
|
List<Contact> existingContacts = [SELECT Id FROM Contact WHERE Email = :email LIMIT 1];
|
||||||
|
System.debug('Found ' + existingContacts.size() + ' contacts with the same email');
|
||||||
|
|
||||||
|
if (!existingContacts.isEmpty()) {
|
||||||
|
throw new AuraHandledException('A contact with this email already exists.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no duplicate found, create new contact
|
||||||
|
Contact newContact = new Contact();
|
||||||
|
newContact.FirstName = fname;
|
||||||
|
newContact.LastName = lname;
|
||||||
|
newContact.Email = email;
|
||||||
|
|
||||||
|
try {
|
||||||
|
insert newContact;
|
||||||
|
System.debug('Successfully created contact with email: ' + email);
|
||||||
|
} catch (DmlException e) {
|
||||||
|
System.debug('Error while creating contact: ' + e.getMessage());
|
||||||
|
throw new AuraHandledException('An error occurred: ' + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>59.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
public class ContactFormController {
|
||||||
|
|
||||||
|
public string FirstName { set; get; }
|
||||||
|
public String LastName { set; get; }
|
||||||
|
public String Email { set; get; }
|
||||||
|
public String Phone { set; get; }
|
||||||
|
public Boolean disabl {set;get; }
|
||||||
|
Contact con = new Contact();
|
||||||
|
|
||||||
|
|
||||||
|
// checking condition and passing value
|
||||||
|
public ContactFormController()
|
||||||
|
{
|
||||||
|
disabl=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void change(){
|
||||||
|
System.debug('Change is Running now');
|
||||||
|
if (String.isNotBlank(FirstName) && String.isNotBlank(LastName) && String.isNotBlank(Email) && String.isNotBlank(Phone)){
|
||||||
|
disabl = false; // If all fields are filled, enable the submit button
|
||||||
|
} else {
|
||||||
|
disabl = true; // If any field is empty, disable the submit button
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//saving into contact
|
||||||
|
//
|
||||||
|
public void insertAcc(){
|
||||||
|
try {
|
||||||
|
con.FirstName = FirstName;
|
||||||
|
con.LastName = LastName;
|
||||||
|
con.Email = Email;
|
||||||
|
con.Phone = Phone;
|
||||||
|
insert con;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Handle the exception here
|
||||||
|
System.debug('Error: ' + e.getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// calling next vf page
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,161 @@
|
||||||
|
public class Controller {
|
||||||
|
|
||||||
|
// This method is called when a new ContentDocument is inserted
|
||||||
|
public static void ControllerMethod(List<ContentDocument> cdlist) {
|
||||||
|
try {
|
||||||
|
String cdid = '', Title = '';
|
||||||
|
// Iterating over the inserted ContentDocuments
|
||||||
|
for (ContentDocument cd : cdlist) {
|
||||||
|
cdid = cd.Id;
|
||||||
|
Title = cd.Title;
|
||||||
|
}
|
||||||
|
// Debugging the data
|
||||||
|
system.debug('@@@@ getting data' + cdlist + 'ontent Document id:' + cdid);
|
||||||
|
// Calling the checkDoc method with the Id and Title of the last ContentDocument in the list
|
||||||
|
Controller.checkDoc(cdid, Title);
|
||||||
|
} catch (Exception e) {
|
||||||
|
system.debug('Error in ControllerMethod: ' + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This future method is used to perform operations that need to be done asynchronously
|
||||||
|
@future
|
||||||
|
public static void checkDoc(String docId, String Title) {
|
||||||
|
try {
|
||||||
|
// Fetching all ContentDocumentLink records associated with the given ContentDocument Id
|
||||||
|
List<ContentDocumentLink> cdlList = [SELECT Id,LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId = :docId];
|
||||||
|
system.debug('@@@@@ ContentDocumentLink Record:' + cdlList+'Title of content document:'+ Title);
|
||||||
|
|
||||||
|
List<Id> LinkedEntyId = new List<Id>();
|
||||||
|
// Extracting the LinkedEntityIds from the fetched ContentDocumentLink records
|
||||||
|
for (ContentDocumentlink cd1 : cdlList) {
|
||||||
|
LinkedEntyId.add(cd1.LinkedEntityId);
|
||||||
|
}
|
||||||
|
system.debug('@@@@@ LinkedEntityId' + LinkedEntyId);
|
||||||
|
|
||||||
|
// Fetching all Contact records associated with the LinkedEntityIds
|
||||||
|
List<Contact> cList = [SELECT Id, LastName, Profile_Image__c, Image_url__c, Description FROM Contact WHERE Id = :LinkedEntyId];
|
||||||
|
system.debug('Contact list where attachment is added' + cList);
|
||||||
|
|
||||||
|
// Fetching the ContentVersion record associated with the given ContentDocument Id
|
||||||
|
ContentVersion cv = [SELECT Id, ContentBodyId FROM ContentVersion WHERE ContentDocumentId = :docId];
|
||||||
|
system.debug('@@@@@ contentVersion records:' + cv);
|
||||||
|
|
||||||
|
List<Contact> updatedContacts = new List<Contact>();
|
||||||
|
for (Contact contact : cList) {
|
||||||
|
if (Title.containsIgnoreCase('Profile')) {
|
||||||
|
// If the title of the document contains 'Profile', updating the Image_url__c and Description fields of the Contact record
|
||||||
|
contact.Image_url__c = 'https://suprnova-dev-ed.develop.file.force.com/sfc/servlet.shepherd/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=' + cv.Id + '&operationContext=CHATTER&contentId=' + cv.ContentBodyId;
|
||||||
|
contact.Description = 'Profile Photo Updated';
|
||||||
|
}
|
||||||
|
updatedContacts.add(contact);
|
||||||
|
}
|
||||||
|
// Updating the Contact records
|
||||||
|
update updatedContacts;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
system.debug('Error in checkDoc: ' + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static Id linkedEntityId;
|
||||||
|
|
||||||
|
// This method is called when a ContentDocument is deleted
|
||||||
|
public static void deletemethod(List<ContentDocument> cdlist){
|
||||||
|
|
||||||
|
String oldId='';
|
||||||
|
// Iterating over the deleted ContentDocuments
|
||||||
|
for(ContentDocument p:cdlist){
|
||||||
|
oldId=p.Id;
|
||||||
|
}
|
||||||
|
system.debug('@@@@@ deleted document id:'+oldId);
|
||||||
|
ContentDocumentLink cdl = [SELECT LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId = :oldId LIMIT 1];
|
||||||
|
system.debug('@@@@@cdl:'+cdl);
|
||||||
|
linkedEntityId = cdl.LinkedEntityId;
|
||||||
|
system.debug('@@@@@linkedEntityId:'+linkedEntityId);
|
||||||
|
|
||||||
|
// Calling the checkDoc2 method with the Id of the last deleted ContentDocument in the list
|
||||||
|
Controller.checkDoc2(linkedEntityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This future method is used to perform operations that need to be done asynchronously after a ContentDocument is deleted
|
||||||
|
@future
|
||||||
|
public static void checkDoc2(Id linkedEntityId){
|
||||||
|
|
||||||
|
try{
|
||||||
|
system.debug('Entered In delete Method'+linkedEntityId);
|
||||||
|
|
||||||
|
// Fetching the LinkedEntityId from the ContentDocumentLink record associated with the given ContentDocument Id
|
||||||
|
// ContentDocumentLink odlEntityId=[SELECT LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId=:docId2];
|
||||||
|
// system.debug('@@@@@ linked entity id:'+odlEntityId);
|
||||||
|
|
||||||
|
// Fetching all ContentDocuments related to the same Contact as the deleted document
|
||||||
|
ContentDocumentLink allRelatedCd=[SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId=:linkedEntityId];
|
||||||
|
system.debug('###allRelatedCd'+allRelatedCd);
|
||||||
|
List<ContentDocument> idTitles=[SELECT Id,Title FROM ContentDocument WHERE Id=:allRelatedCd.ContentDocumentId ];
|
||||||
|
List<Id>idofProfile=new List<Id>();
|
||||||
|
|
||||||
|
for(ContentDocument vb:idTitles){
|
||||||
|
if(vb.Title.containsIgnoreCase('Profile')){
|
||||||
|
idofProfile.add(vb.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
system.debug('@@@@@ idofProfile'+idofProfile);
|
||||||
|
|
||||||
|
// Fetching the latest ContentDocument with a title containing 'Profile'
|
||||||
|
ContentDocument contentList0=[SELECT Id,Title FROM ContentDocument WHERE Id =:idofProfile ORDER BY CreatedDate DESC LIMIT 1];
|
||||||
|
system.debug('@@@@@ ids of profile named files:'+ contentList0);
|
||||||
|
|
||||||
|
List<Contact> updatedContacts = new List<Contact>();
|
||||||
|
// Fetching all Contact records associated with the LinkedEntityId
|
||||||
|
List<Contact>cList=[SELECT Id,LastName,Profile_Image__c,Image_url__c,Description FROM Contact WHERE Id =:linkedEntityId];
|
||||||
|
system.debug('Contact list where attachment is added'+cList);
|
||||||
|
// Storing the Id and title of the fetched ContentDocument
|
||||||
|
if(contentList0!=null){
|
||||||
|
String profileid=contentList0.Id;
|
||||||
|
String Title=contentList0.Title;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
system.debug('@@@@@ List of ids:'+profileid);
|
||||||
|
system.debug('@@@@@ List of ids:'+Title);
|
||||||
|
|
||||||
|
// Fetching the LinkedEntityId from the ContentDocumentLink record associated with the fetched ContentDocument
|
||||||
|
//List<ContentDocumentLink>cdLinkList=[SELECT Id,LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId=:profileid];
|
||||||
|
|
||||||
|
// String entityId='';
|
||||||
|
//for(ContentDocumentLink cdo:cdLinkList){
|
||||||
|
// entityId=cdo.LinkedEntityId;
|
||||||
|
//}
|
||||||
|
//system.debug('@@@@ linked entity id :'+ entityId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Fetching the ContentVersion record associated with the fetched ContentDocument
|
||||||
|
ContentVersion cv = [SELECT Id,ContentBodyId FROM ContentVersion WHERE ContentDocumentId = :profileid];
|
||||||
|
system.debug('@@@@@ contentVersion records:'+cv);
|
||||||
|
|
||||||
|
|
||||||
|
// Updating the Contact records
|
||||||
|
for (Contact contact : cList) {
|
||||||
|
contact.Image_url__c='https://suprnova-dev-ed.develop.file.force.com/sfc/servlet.shepherd/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId='+cv.Id+'&operationContext=CHATTER&contentId='+cv.ContentBodyId;
|
||||||
|
contact.Description = 'previous profile photo updated';
|
||||||
|
updatedContacts.add(contact);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for (Contact contact : cList) {
|
||||||
|
contact.Image_url__c='No profile';
|
||||||
|
contact.Description = 'No previous profile ';
|
||||||
|
updatedContacts.add(contact);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update updatedContacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(Exception e){
|
||||||
|
System.debug('@@@@@@ error:'+e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
public class ConvertingLeads {
|
||||||
|
@InvocableMethod
|
||||||
|
public static void assignLeads(List<Id>LeadIds){
|
||||||
|
LeadStatus cLeadStatus=[Select Id,MasterLabel from LeadStatus where isConverted=true limit 1];
|
||||||
|
List <lead> massLeadConvert=new List<lead>();
|
||||||
|
List<Database.LeadConvert> dl=new List<Database.LeadConvert>();
|
||||||
|
for(Id currentLead:LeadIds){
|
||||||
|
Database.LeadConvert LeadConvert=new Database.LeadConvert();
|
||||||
|
LeadConvert.setLeadId(currentLead);
|
||||||
|
LeadConvert.setConvertedStatus(cLeadStatus.MasterLabel);
|
||||||
|
LeadConvert.setDoNotCreateOpportunity(False);
|
||||||
|
dl.add(LeadConvert);
|
||||||
|
}
|
||||||
|
if(!dl.isEmpty()){
|
||||||
|
List <Database.LeadConvertResult>lcr=Database.convertLead(dl);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
public class CopyAttachmentHandler {
|
||||||
|
public static void copyAtt(List<ProjectDemo__c>pdList){
|
||||||
|
try{
|
||||||
|
|
||||||
|
//releted opp id
|
||||||
|
Set<ID> OppId = new Set<ID>();
|
||||||
|
Set<ID> CdId = new Set<ID>();
|
||||||
|
|
||||||
|
// related attachment id of opp id
|
||||||
|
Set<ID> attId = new Set<ID>();
|
||||||
|
|
||||||
|
for(ProjectDemo__c pd1:pdList){
|
||||||
|
OppId.add(pd1.Opportunity_Name__c);
|
||||||
|
}
|
||||||
|
System.debug('@@@@@@ oppid'+OppId);
|
||||||
|
|
||||||
|
for(ContentDocumentLink ac:[SELECT Id,ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId IN:OppId]){
|
||||||
|
attId.add(ac.Id);
|
||||||
|
CdId.add(ac.ContentDocumentId);
|
||||||
|
}
|
||||||
|
System.debug('@@@@@@ Attid'+attId);
|
||||||
|
System.debug('@@@@@@ CdId'+CdId);
|
||||||
|
|
||||||
|
list<ContentVersion> newContentVersion=new list<ContentVersion>();
|
||||||
|
list<ContentDocumentLink> cdl=new list<ContentDocumentLink>();
|
||||||
|
|
||||||
|
List<ContentVersion> attachmentList = [SELECT Id, VersionData,Description, Title, ContentBodyId, ContentDocumentId FROM ContentVersion WHERE ContentDocumentId IN:CdId];
|
||||||
|
System.debug('@@@@@@ attachmentList'+attachmentList);
|
||||||
|
|
||||||
|
|
||||||
|
for(ContentVersion att: attachmentList) {
|
||||||
|
ContentVersion newFile = new ContentVersion();
|
||||||
|
newFile.Title = att.Title;
|
||||||
|
newFile.ContentBodyId = att.ContentBodyId;
|
||||||
|
|
||||||
|
newFile.Description=att.Description;
|
||||||
|
newContentVersion.add(newFile);
|
||||||
|
}
|
||||||
|
insert newContentVersion;
|
||||||
|
|
||||||
|
|
||||||
|
List<Id> CdIdid = new List<Id>();
|
||||||
|
|
||||||
|
for(ContentVersion cvv:newContentVersion){
|
||||||
|
CdIdid.add(cvv.ContentDocumentId);
|
||||||
|
}
|
||||||
|
System.debug('@@@@@@ new content documnet id'+CdIdid);
|
||||||
|
|
||||||
|
|
||||||
|
for(ProjectDemo__c pd:pdList){
|
||||||
|
ContentDocumentLink newLink= new ContentDocumentLink();
|
||||||
|
newLink.LinkedEntityId=pd.Id;
|
||||||
|
for(Id ccd:CdIdid){
|
||||||
|
newLink.ContentDocumentId=ccd;
|
||||||
|
}
|
||||||
|
cdl.add(newLink);
|
||||||
|
}
|
||||||
|
insert cdl;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(Exception e){
|
||||||
|
system.debug('@@@@ Error'+e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
|
||||||
|
<apiVersion>58.0</apiVersion>
|
||||||
|
<status>Active</status>
|
||||||
|
</ApexClass>
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
public with sharing class FileController{
|
||||||
|
@AuraEnabled(cacheable=true)
|
||||||
|
public static List<ContentVersion> getVersionFiles(String recordId){
|
||||||
|
try {
|
||||||
|
return [
|
||||||
|
SELECT
|
||||||
|
Id,
|
||||||
|
Title,
|
||||||
|
ContentDocumentId,
|
||||||
|
FileType,
|
||||||
|
ContentSize,
|
||||||
|
FileExtension,
|
||||||
|
VersionNumber,
|
||||||
|
CreatedDate,
|
||||||
|
VersionData,
|
||||||
|
FirstPublishLocationId
|
||||||
|
FROM ContentVersion
|
||||||
|
WHERE FirstPublishLocationId =:recordId
|
||||||
|
ORDER BY CreatedDate DESC
|
||||||
|
];
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new AuraHandledException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue