+ Start a Discussion
Kumar Saurav 16Kumar Saurav 16 
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 });
}
                 
    }   
}

 
Best Answer chosen by Kumar Saurav 16
SEKAR RAJ 19SEKAR RAJ 19
Hi Kumar,
Change the query where condition like below ,
String Query = 'SELECT ABI_SFA_Account_Removal__c FROM ABI_SFA_TerritoryAccountChange__c WHERE ABI_SFA_Account__r.name like 'Europromotion%'  LIMIT 50000';


Thanks,
SEKAR RAJ
Bob_poliquinBob_poliquin 
I have created a new opportunity button to create products. The button is working, but it keeps returning back to the beginning of the flow.

How would I change that behavor in the link to returning back to the opportunity record?

https://acme.lightning.force.com/flow/Create_Yushin_Products?recordId={!Opportunity.Id}

User-added image
Best Answer chosen by Bob_poliquin
Dominic McCarthyDominic McCarthy
Hi Bob,
If you put the following at the end of your URL: &retURL=%2F{!Opportunity.Id} it will return to the Opportunity record. 
Hope that works or my first answer here is a dud!
Thank you!
Yours,
Dominic.
SFDC16SFDC16 
Schedulbale Class:

User-added image

global class DeletAccount implements Schedulable
{
     
     global void execute(SchedulableContext ctx)
     {
         list<Account> acc=new list<Account>();
         for(Account acc1:[Select id,name from account where name like '%Demo%'])        
             acc.add(acc1);--------------->Error Line
             
   
         delete acc;      
     }
       
}

Test Class:

@isTest
public class Testclass {
 public static testmethod void test1()
 {
     Test.startTest();
           list<account> acc=new list<Account>(); 
        Account a1 = new Account();
          a1.name='Dummy account';
         acc.add(a1);    
         insert acc; 
        String CRON_EXP = '0 0 0 3 9 ? 2022';
        String jobId = System.schedule('test111', CRON_EXP, new DeletAccount());
         CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
          System.debug('ct'+ct);
        System.assertEquals(0, ct.TimesTriggered);
        System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime));
     Test.stopTest();  
 }
                
}
 
Best Answer chosen by SFDC16
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

In business class, you are fetching account where name consists of Demo. So, in a test class, you need to insert account name which has 'demo' in it.

Try below code:
@isTest
public class Testclass {
 public static testmethod void test1()
 {
     Test.startTest();
           list<account> acc=new list<Account>(); 
        Account a1 = new Account();
          a1.name='Dummy Demo account';
         acc.add(a1);    
         insert acc; 
        String CRON_EXP = '0 0 0 3 9 ? 2022';
        String jobId = System.schedule('test111', CRON_EXP, new DeletAccount());
         CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
          System.debug('ct'+ct);
        System.assertEquals(0, ct.TimesTriggered);
        System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime));
     Test.stopTest();  
 }
                
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Stephen Glaros 7Stephen Glaros 7 
Hi Community,

I'm trying to create a simple formula that returns text when a checkbox is checked. 

I have the checkbox field and a field for the text to be diplayed:
IF( SOW_Name__r.All_Deliverables_owned_by_Company__c = TRUE,  Deliverable_Ownership__c "All Deliverables owned by Company")
and the error code I'm getting is "Syntax error. Found Deliverable_Ownership__c", which is the field I want the text to display in.

Any ideas what I'm doing wrong? Thx!
 
Best Answer chosen by Stephen Glaros 7
Ajay K DubediAjay K Dubedi
Hi Stephen,

Create a 'Deliverable_Ownership__c' formula field of type text in Child Object and apply the following formula in that field:
if(SOW_Name__r.All_Deliverables_owned_by_Company__c,"All Deliverables owned by Company",' ')

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
knght4yshuaknght4yshua 
I have the following code:
 
<lightning:select aura:id="requestTypeSelect" 
                           name="requestTypeSelect" 
                           label="I'd like to: " 
                           required="true" 
                           value="{!v.requestTypeName}" 
                           onchange="{!c.setRequestTypeCmp}"
                           class="font">
The font size of the label "I'd like to:" is small and I'd like to increase it.  Changing the font in any way via a class, like "font" above, only changes the font within the select menu, not the label itself.

Is this possible?

Thanks!
 
Best Answer chosen by knght4yshua
Ajay K DubediAjay K Dubedi
Hi,
Done change your component code:
<lightning:select aura:id="requestTypeSelect"
                  name="requestTypeSelect"
                  label="I'd like to: "
                  required="true"
                  value="{!v.requestTypeName}"
                  onchange="{!c.setRequestTypeCmp}"
                  class="font">
    <option value="">-- None --</option>
    <aura:iteration items="{!v.requestTypeNames}" var="requestTypeName">
        <option value="{!requestTypeName}">{!requestTypeName}</option>
    </aura:iteration>
</lightning:select>
And just change the CSS from the Style section of lightning component and add these lines :
.THIS .slds-form-element__label{
    font-size: 1.75rem !important;
}

User-added image

Thanks
Ajay Dubedi

HarithaAkellaHarithaAkella 
I figured out that the pagination:

<apex:pageBlockButtons location="Bottom">
<apex:commandLink value="First" action="{!First}"/> &nbsp;
<apex:commandLink value="Next" action="{!Next}"/> &nbsp;
<apex:commandLink value="Previous" action="{!Previous}"/> &nbsp;
<apex:commandLink value="Last" action="{!Last}"/>
</apex:pageBlockButtons>

my next and prev links implemented as above work fine when I have pageblocktable fields as
<apex:column value="{!ord.SO__c}" style="width: 20px; height: 20px"/>

Once you change to InputText value, that's when I see the error "Modified rows exist in the records collection! "
<apex:column> <apex:InputText value="{!ord.SO__c}" style="width: 20px; height: 20px"/>  </apex:column>

But I have the requirement to have input fields in my pageblocktable in visualforce page,  I just dont want to view them, i should be able to edit them but also have the pagination work preoperly!
Best Answer chosen by HarithaAkella
HarithaAkellaHarithaAkella
Ok, I have found the solution for this! Just change the <apex:InputText > to <apex:InputField> , That solves the issue!
jamie moffattjamie moffatt 
Can I Get number of api calls made in the last 24 hours via the API. This is to check if we are close to the limit before making bulk calls.

Please note this needs to be via the API I know how to access this via the UI but im looking to modify a windows service to check before making bulk calls. 
Best Answer chosen by jamie moffatt
Khan AnasKhan Anas (Salesforce Developers) 
Hi Jamie,

Greetings to you!

You can use Limits from REST API.

/services/data/v45.0/limits

You can see your overall API usage stats by using the REST explorer in Workbench (https://workbench.developerforce.com/restExplorer.php) and then doing a GET of '/services/data/v45.0/limits'. Look for DailyApiRequests and open that and it will show you how many calls you are allows and how many you have left.

Please refer to the below link which might help you further.

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_limits.htm

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
roni shoreroni shore 
Hi Guys- can anyone help out on this, I want to schedule a batch so it runs thrice at 23:00, 1:40 & 4:00

String cronStr = '0 45 23,1,4 * * ?';

Hours I can specify comma seperated but minutes it's not taking, pls suggest
Best Answer chosen by roni shore
Khan AnasKhan Anas (Salesforce Developers) 
Hi Roni,

Greetings to you!

CRON in Apex do not support comma separated parameters in Minutes and Seconds.

You can schedule 3 instances:
public static String CRON_STR = '0 0 23 * * ?';  // For 23:00
public static String CRON_STR_2 = '0 40 1 * * ?';  // For 1:40
public static String CRON_STR_3 = '0 0 4 * * ?';   // For 4:00

Then schedule it:
System.schedule('Job 1', CRON_STR, new YourClass()); 
System.schedule('Job 2', CRON_STR_2, new YourClass());
System.schedule('Job 3', CRON_STR_3, new YourClass());

Please refer to the below link which might help you further with the above requirement.

https://salesforce.stackexchange.com/questions/83774/how-to-schedule-a-job-twice-a-day

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Angel Zaykov 40Angel Zaykov 40 
Hi all,

I want to invoke a lightning component from a list button.

Everything works fine except if I use "e.force:createRecord".

Here's the error message: 
This page has an error. You might just need to refresh it. Action failed: c:leadCollector$controller$createRecordHelper [Cannot read property 'setParams' of undefined] Failing descriptor: {c:leadCollector$controller$createRecordHelper}

Any piece of advice would be greatly appreciated.
Thanks
Best Answer chosen by Angel Zaykov 40
Khan AnasKhan Anas (Salesforce Developers) 

Hi Zaykov,

Greetings to you!

You cannot use force:createRecord event in visualforce. According to Salesforce doc (https://developer.salesforce.com/docs/component-library/bundle/force:createRecord/documentation): 

This event is handled by the one.app container. It’s supported in Lightning Experience, the Salesforce app, and Lightning communities. This event presents a standard page to create a record. That is, it doesn’t respect overrides on the object’s create action.

Please refer to the below link which might help you further with the above requirement.

https://salesforce.stackexchange.com/questions/124405/lightning-issue-while-calling-createrecord-event-component

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

PMPR72PMPR72 
I have a requirement that I have to fetch all the Account Lookup fields.I'm using Schema.DisplayType for fetching Text,Picklistlist fields.But for lookup fields I don't know how to fetch.Can anyone help me?
Best Answer chosen by PMPR72
Abhishek BansalAbhishek Bansal
Hi,

For lookup fields please use the Reference keyword. Below is the sample code for your help:
String objType = 'Account';
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType leadSchema = schemaMap.get(objType);
Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();

for (String fieldName: fieldMap.keySet()) {
    //get all the fields label for Account Object
    String fieldLabel = fieldMap.get(fieldName).getDescribe().getLabel();

    //get data types for each fields
    Schema.DisplayType fielddataType = fieldMap.get(fieldName).getDescribe().getType();
    if(fielddataType == Schema.DisplayType.Reference) {
        system.debug('Field Label===='+fieldLabel);
    }
}

Please let me know if you need any further help on this.

Thanks,
Abhishek Bansal.