• SEKAR RAJ.
  • NEWBIE
  • 245 Points
  • Member since 2019
  • Sr.Salesforce Developer
  • Tech Mahindra

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 52
    Replies
In Apex, how do a append text to an existing field? 
Hello,

I have a usecase for docusign, where a marketing guy/girl clicks on a doc and once the doc is opened a customer signs it and once signed, an email is sent.

What are various bricks or what is solution in decomposed maner.

Thank you for suggestion
  • June 20, 2019
  • Like
  • 0
global class ABI_SFA_TAC_Removal_Batch implements Database.batchable<sObject>
{    
    // variable decleration.
    public String Query;
               
     /* 
     Method Name: Start
     Description: This method is used to collect the TAC records ready for deletion.     
    */
    global Database.QueryLocator Start(Database.BatchableContext info)
    { 
       // fetch TAC records ready for removal.
        
		String Query = 'SELECT ABI_SFA_Account_Removal__c,ABI_SFA_Account__c,ABI_SFA_RecordID__c,ABI_SFA_SHAREID__c, ABI_SFA_Type__c,ABI_SFA_User__c,ABI_SFA_Valid_Till__c,CreatedById,CreatedDate,CurrencyIsoCode,Id,IsDeleted,LastModifiedById,LastModifiedDate,Name,OwnerId,SystemModstamp FROM ABI_SFA_TerritoryAccountChange__c WHERE ABI_SFA_Account__r.name like '%Europromotion%' LIMIT 50000';
       
       return Database.getQueryLocator(query);  
    }
      
    /*
     Method Name: Execute
     Description: This method is used to process the TAC records that are passed from Start method.   
    */     
    global void Execute(Database.BatchableContext info, List<ABI_SFA_TerritoryAccountChange__c> tacList)
    {
	    if(tacList!=Null && tacList!=Empty){
			System.debug('@@@inside IF block');
			try {
				System.debug('@@@inside TRY block');
				Database.DeleteResult[] TAC_Dels = Database.delete(tacList);
			}
			catch (DmlException e) {
				System.debug('@@@ The following exception has occurred: ' + e.getMessage());
				ApexPages.addMessage(myMsg);
				ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,<strong>string.valueof(e)</strong>); 
			}
	    }
    }
	
	
    /*
     Method Name: Finish
     Description: This method is used to notify all relevant stakeholders via Email.      
    */       
    global void Finish(Database.BatchableContext info){ 

		String Email;
		List<ID> tacERId = new List<ID>();
		public void SendEmail() {
		for(TACEmailRecipients__c tacER: TACEmailRecipients__c.getAll().values());{
			tacERId.add(tacER.Id);
		}
		
		EmailTemplate et=[Select id from EmailTemplate where name = 'TAC_Notification' limit 1];

		Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
		mail.setTargetObjectIds(tacERId);
		mail.setSenderDisplayName('Acenture Support Team');
		mail.setTemplateId(et.id);
		Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
}
                 
    }   
}

 
Error:Apex trigger Test caused an unexpected exception, contact your administrator: Test: execution of AfterUpdate caused by: System.StringException: Invalid id: Dickenson Mobile Generators: Trigger.Test: line 8, column 1
Scenario: whenever the stage field changed to Close won in opportunities , a new object record (Litrack__c)should be created.
Code:
trigger Test on Opportunity (after update) {
    Map<Id,Litrack__c> LitInsert= new Map<Id,Litrack__c>();
    for(Opportunity opNew: Trigger.new){
        for(Opportunity opOld: Trigger.old){
            if(opNew.StageName!=opOld.StageName && opNew.StageName=='Closed Won'){
                Litrack__c Record = new Litrack__c();
                Record.Name=opNew.id;
                Record.Opportunity_Lookup__c=opNew.Name;
                LitInsert.put(Record.id,Record);
            }
        }
      
                insert LitInsert.values();
             
}
}
I have an end user who is asking me to create a formula to do the following and I'm not even sure this is possible, so I'm asking for some input from the community if this formula can even be created

The formula she is requesting is this:

If Ground Break Photos Upload Date >/= -14 days from Ground Break Date then Ground Break Report Due = Ground Break Date -7 days. 

I've tried using the >= - 14  but I get an error message. I think it because of the Ground Break Photos Upload Date is a Date/Time field. So I'm not sure how to create a formula to handle that. 

Any help is greatly appreciated. 

Thanks,

Glenn
Hi All,
My test class is given below:-
// Test class for BatchResellerPartnerToResellerCustomer
@isTest
private class BatchResellerCustomerTest {
static testmethod void TestResellerCustomer(){
// Check the API Name
Id recId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Time Rack').getRecordTypeId();
Account acc =new Account( Name = 'test' ,Customer_Type__c ='Reseller' ,recordtypeid = recId );
insert acc;
//List<Opportunity> oppList = new List<Opportunity>();
// Opportunity Name with '-'
Opportunity opp = new Opportunity();
opp.StageName = 'Sourcing Demand';
opp.AccountId = acc.id;
opp.CloseDate = System.today();
opp.Name = 'test -ExPay';
insert opp;
// Opportunity Name with ':'
Opportunity oppt = new Opportunity();
oppt.StageName = 'Sourcing Demand';
oppt.AccountId = acc.id;
oppt.CloseDate = System.today();
oppt.Name = 'test :RePay';
insert oppt;
//opportunity Name other than '-' and ':'
Opportunity oppty = new Opportunity();
oppty.StageName = 'Sourcing Demand';
oppty.AccountId = acc.id;
oppty.CloseDate = System.today();
oppty.Name = 'test Pay';
insert oppty;
test.startTest();
BatchResellerPartnerToResellerCustomer obj = new BatchResellerPartnerToResellerCustomer();
database.executeBatch(obj);
Set<Id> OppIds = new Set<Id>();
OppIds.add(opp.Id);
BatchResellerPartnerToResellerCustomer.run(OppIds);
test.stopTest();
}
}
how to put Asserts in this test class to make it better?
Any suggestions?
I recently started using related contacts and I have been setting up contacts that related to multiple accounts, but I want to easily be able to see a list of the accounts they are related to.  Ideally I would love to click on the contact name and have them listed on the contact card or something similar.
I have to query and update a remote site setting after sandbox refresh. Is anyone know how to query remote site settings records?
Hi,
I have a requirement, where in a financial system we do arround 1 million transactions per day. Now my requirement is to push these records in Salesforce everyday in a nightly batch. Can someone help me if this bulk load is possible using a batch job scheduled in SF? Would I hit any governer limit?
In Apex, how do a append text to an existing field? 
Can we import SurveySubjects through Workbench?
Hello Everyone,

I need your help, I am trying to fetch data from a apex class and store it in a list. The list basically has a custom object data. now when i render it in a table and show in the html , i display the values in a table and use input fields to show. Now when i change the values from the front end it does not stores in the track variable. I know there should be some java script magic, can you help to figure out what ?

HTML:

 <template for:each={budgetData} for:item="budget"> 
                <tr key={budget.Id} class="slds-hint-parent">
                    <td >
                        <div class=" headingBG" >{budget.BG_Code__c}</div>
                    </td>
                    <td >
                        <div class=" headingBG" >{budget.BG_Name__c}</div>
                    </td>
                    <td >
                        <div class=" headingBG" >{budget.Category_Code__c}</div>
                    </td>
                    <td >
                        <div class=" headingBG" >{budget.Category_Name__c}</div>
                    </td>
                    <td >
                        
                        <div class="slds-truncate" >
    
                            <lightning-input type="text" id={budget.Id} name={budget.Upselling_Investment__c} value={budget.Upselling_Investment__c} disabled={disableFieldBudget} onchange={onchangevalues} >
                            </lightning-input>
                        </div>
                    </td>
                    <td >
                        <div class="slds-truncate" >
                            <lightning-input type="text"  value={budget.Retailer_promotion_STTI__c} disabled= {disableFieldBudget}   ></lightning-input>
                        </div>
                    </td>
                    <td >
                        <div class="slds-truncate" >
                            <lightning-input type="text"  value={budget.Consumer_promotion__c} disabled={disableFieldBudget} ></lightning-input>
                        </div>
                    </td>
                     <td >
                        <div class="slds-truncate" >
                            <lightning-input type="text"  value={budget.Brand_investment__c} disabled={disableFieldBudget} ></lightning-input>
                        </div>
                    </td>
                    <td >
                        <div class="slds-truncate" >
                            <lightning-input type="text"  value={budget.Cooperative_advertising_KAM__c} disabled={disableFieldBudget} ></lightning-input>
                        </div>
                    </td>


So when the value which comes is a list and i store it in a track. Now when i want to update i should call a onchange method may be.

 
I have been messing around with the LWC OSS Components (https://lwc.dev/)... 

But I am a little lost, I assumed there would have been a straight forward way of retrieving data from a DB or even from Salesforce...

I wanted to use something like Passport along with Mongoose (NodeJS modules), to authenticate then to retrieve data from a MongoDB, to then display stuff out there... but I can't seem to get this to work and I can't find any info online about this yet either :/
Hello,

I have a usecase for docusign, where a marketing guy/girl clicks on a doc and once the doc is opened a customer signs it and once signed, an email is sent.

What are various bricks or what is solution in decomposed maner.

Thank you for suggestion
  • June 20, 2019
  • Like
  • 0
Hi,

I am in Lightning and I am currently using Salesforce's standard functionality of adding products on an opportunity.

As we have different types of products, when the users are selecting the products from the Add Products page and click the button Next, I want to be able to hide a Lookup field to a custom object I have created on the OLI - depending on the type of product selected. 

Also, when the Lookup field is showing on the OLI for some of the products, I want to prepoluate another two fields from the OLI with the values of the records from the Lookup field.

Is it possible to achieve this only by creating an Apex code? Without having to create a Visualforce page?


Thanks a lot.
can i pass variables of one ampscript to another, i want to set value for a variable in one ampscript and want to use the same variable in another ampscript.
Hello,

I have the contract standard object which has several record types.
in case i have the record type vendor purchases the user will need to insert another contract code. So contract standard obejct has a look up field to itself.
I would like in case i have the record type vendor-purchases, when i insert the contract code it is related with, to automatically insert the Account id.
This is what i've dove done but i get error " A non foreign key field cannot be referenced in a path expression: Maintenance_Contract__c at line 8 column 27"
trigger Vendor on Contract (before insert,before update) {
    
    for (Contract c : Trigger.new)
    {
        
        if (c.RecordTypeId=='0120Q0000004gQO')
        {
            c.AccountId=c.Maintenance_Contract__c.AccountID;
        }
        
        
    }
}

An example of the layout
User-added image
Hello Developer,

My  Http callouts in batch class not working.

But normal class working fine 

I converted my lightning:combobox into slds combobox to use data attributes, now, dropdown is not showing. Please help me.

And also, how to put the selected item into input textbox?

<aura:attribute name="myObject" type="List"/>
<aura:attribute name="myCustomSettings" type="MyCustomSettings__c[]"/>

<aura:iteration items="{!v.myCustomSettings}" var="obj" indexVar="index">
	<tr class="slds-hint-parent">
		<td role="gridcell" data-label="Object">
			<div class="slds-form-element slds-form-element__control">
				<div class="slds-combobox_container">
					<div aura:id="open" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click" aria-expanded="true" aria-haspopup="listbox" role="combobox">
						<div class="slds-combobox__form-element slds-input-has-icon slds-input-has-icon_right" role="none">
							<input type="text" class="cellField slds-input slds-combobox__input" role="textbox" autocomplete="off" readonly="true"
									aura:id="allObjects"
									placeholder="-Select-"
									data-id="{!'index-' + index + 1}"
									data-value="{!index + 1}"
									value="{!obj.Object__c}"
									onfocus="{!focus}"/>
							<span class="slds-icon_container slds-icon-utility-down slds-input__icon slds-input__icon_right">
								<lightning:icon class="slds-icon slds-icon-text-default slds-icon_xx-small" iconName="utility:down" size="xx-small" variant="brand" />
							</span>
						</div>
						<div aura:id="options" class="slds-dropdown slds-dropdown_length-5 slds-dropdown_fluid" role="listbox">
							<ul class="slds-listbox slds-listbox_vertical" role="presentation">
								<aura:iteration items="{!v.myObject}" var="myLst" indexVar="i">
									<li aura:id="selectObj" role="presentation" class="slds-listbox__item" onclick="{!c.itemSelected}" data-id="{!'index-' + i + 1}" data-value="{!i + 1}">
										<div id="{!i + 1 + '-item'}" aura:id="is-selected" class="slds-media slds-listbox__option slds-listbox__option_plain slds-media_small" role="option">
											<span class="slds-media__figure slds-listbox__option-icon"></span>
											<span class="slds-media__body">
												<span class="slds-truncate" title="{!myLst.label}">{!myLst.label}</span>
											</span>
										</div>
									</li>
								</aura:iteration>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</td>
	<tr>
<aura:iteration/>
 
focus : function (component, event, helper) {
	var open = component.find("open");
	$A.util.toggleClass(open, 'slds-is-open');
},
 
itemSelected : function(component, event, helper) {
        var selectedItem = event.currentTarget;
        var id = selectedItem.dataset.id;
        var elements = component.find('selectObj');
        for (var i = 0; i < elements.length; i++) {
            var val = elements[i].getElement().getAttribute('data-id');
            if(val == id) {
                console.log(val);
                //put the selected item to input textbox
            }
        }
    },
I have to query and update a remote site setting after sandbox refresh. Is anyone know how to query remote site settings records?
Hi every one,

i have one scenario we wont to write trigger account and contact will have lookup relation ship if contacts will added automatically in the account object one custom field count will be increse (like lookup relation ship)

how can we acchive this if any one know please help me.
Thank you
Surender Reddy
9603757105
 
Hi All,

I want to include a button to create new contact in lightning component, Could some one provide the logic for it.

Thanks in Advance.
  • May 22, 2019
  • Like
  • 0
I have added a custom button to Quote object including an IF conditional statement , when the statement is true it functions correctly however if false instead of showing error message statement I get URL No Longer Exists error - please see code below. What can I do to fix this?
{!IF( ISPICKVAL( Quote.Status , 'Approved') , 

URLFOR('/apex/dsfs__DocuSign_CreateEnvelope', null, [SourceID = Quote.Id, 
LF='1', 
CRL='Email~'+Quote.Email+';LastName~'+Quote.Full_Name__c+';Role~Signer 1,LoadDefaultContacts~0', 
OCO='Send' 
]), "Quote must be submitted for approval") 
}

 
I have an end user who is asking me to create a formula to do the following and I'm not even sure this is possible, so I'm asking for some input from the community if this formula can even be created

The formula she is requesting is this:

If Ground Break Photos Upload Date >/= -14 days from Ground Break Date then Ground Break Report Due = Ground Break Date -7 days. 

I've tried using the >= - 14  but I get an error message. I think it because of the Ground Break Photos Upload Date is a Date/Time field. So I'm not sure how to create a formula to handle that. 

Any help is greatly appreciated. 

Thanks,

Glenn