-
ChatterFeed
-
5Best Answers
-
0Likes Received
-
0Likes Given
-
11Questions
-
30Replies
How to edit User object field 'Admin Info Emails' ?
User objet in salesforce has a field 'Admin Info Emails'. This field is checkbox. In our org, the users of same profile(customer service profile), this field has different status for different users(of same profile). How to edit this button?
Thanks in advance
Thanks in advance
-
- Pradnya79
- August 08, 2018
- Like
- 0
- Continue reading or reply
Hi Community had written one trigger which displays the child record count(student object) on parent obect (Teacher) below.Code has no errors but output is not coming while inserting or deleting or updating records on child object(student)
trigger studentcount1 on Student__c (after insert,after update,after delete,after undelete) {
set<ID> parentID=new set<ID>();
List<Teacher__c> ParentQueryList=new list<Teacher__c>();
List<Teacher__c> ParentToupdate=new list<Teacher__c>();
If(Trigger.isinsert|| Trigger.isupdate||Trigger.isundelete)
{
for(student__c acc:Trigger.new)
{
if(acc.subject__r.id!=null)
{
parentID.add(acc.subject__r.id);
}
}
}
If(Trigger.isdelete){
for(student__c acc:Trigger.old)
{
if(acc.subject__r.id!=null)
{
parentID.add(acc.subject__r.id);
}
}
}
if(parentID.size()>0)
ParentQueryList=[select id,name,childcount__c,(select id,name,subject__c from students__r) from Teacher__c where ID in :parentID];
system.debug('ParentQueryList--->'+ParentQueryList);
for(Teacher__c tc:ParentQueryList)
{
tc.childcount__c=tc.students__r.size();
ParentToupdate.add(tc);
}
if(ParentToupdate.size()>0)
{
update ParentToupdate;
}
}
set<ID> parentID=new set<ID>();
List<Teacher__c> ParentQueryList=new list<Teacher__c>();
List<Teacher__c> ParentToupdate=new list<Teacher__c>();
If(Trigger.isinsert|| Trigger.isupdate||Trigger.isundelete)
{
for(student__c acc:Trigger.new)
{
if(acc.subject__r.id!=null)
{
parentID.add(acc.subject__r.id);
}
}
}
If(Trigger.isdelete){
for(student__c acc:Trigger.old)
{
if(acc.subject__r.id!=null)
{
parentID.add(acc.subject__r.id);
}
}
}
if(parentID.size()>0)
ParentQueryList=[select id,name,childcount__c,(select id,name,subject__c from students__r) from Teacher__c where ID in :parentID];
system.debug('ParentQueryList--->'+ParentQueryList);
for(Teacher__c tc:ParentQueryList)
{
tc.childcount__c=tc.students__r.size();
ParentToupdate.add(tc);
}
if(ParentToupdate.size()>0)
{
update ParentToupdate;
}
}
-
- Santhosh Kon 5
- August 07, 2018
- Like
- 0
- Continue reading or reply
Bulkify the before insert or update Triggers?
Hi Team,
How can we bulkify this using trigger handler class, please let me know any one.
Trigger :
---------------
I want to bulkify this code using trigger handler class.
Regards,
Lakshmi
How can we bulkify this using trigger handler class, please let me know any one.
Trigger :
---------------
trigger OpportunityTrig on Opportunity (before insert, before update, after insert, after update) { if(Trigger.isBefore && Trigger.isInsert){ for(opportunity op : Trigger.New){ //opportunity o = Trigger.oldmap.get(op.Id); if(op.Close_Deal_Date__c != null){ Integer y = op.Close_Deal_Date__c.YEAR(); Integer m = ((op.Close_Deal_Date__c.MONTH()-1)/3)+1; String q = String.valueOf(y)+' Q'+String.valueOf(m); system.debug('y'+y+' Mon :'+m+' Quarter:'+q); op.Reporting_Quarter__c = q; } else if(op.Close_Deal_Date__c == null){ op.Reporting_Quarter__c = null; } } } if(Trigger.isBefore && Trigger.isUpdate){ OpportunityTriggerHandlerCls.oppCategoryUpdate((List<Opportunity>)Trigger.New); for(opportunity op : Trigger.New){ opportunity o = Trigger.oldmap.get(op.Id); if(op.Close_Deal_Date__c != null && (op.Close_Deal_Date__c != o.Close_Deal_Date__c)){ Integer y = op.Close_Deal_Date__c.YEAR(); Integer m = ((op.Close_Deal_Date__c.MONTH()-1)/3)+1; String q = String.valueOf(y)+' Q'+String.valueOf(m); system.debug('y'+y+' Mon :'+m+' Quarter:'+q); op.Reporting_Quarter__c = q; } else if(op.Close_Deal_Date__c == null && (op.Close_Deal_Date__c != o.Close_Deal_Date__c)){ op.Reporting_Quarter__c = null; } } } }
I want to bulkify this code using trigger handler class.
Regards,
Lakshmi
-
- Lakshmi S
- August 06, 2018
- Like
- 0
- Continue reading or reply
Days between two DateTime values excluding weekends
Hello,
I need to calculate hours between two DateTime objects in apex excluding non-working days and weekends. Here is my method:
// calculate working hours between createdDate and completedDate private Integer calculateWorkingHours(Datetime createdDate, Datetime completedDate) { List<BusinessHours> bhList = [Select id From BusinessHours Where IsDefault=true]; if(bhList.size() == 0) { //If there is a problem to get hours from the BusinessHours database table return -1 return -1; } // Get id of used set of business hours String bhId = bhList.get(0).id; // Returns the difference in milliseconds between a start and end Datetime based on a specific set of business hours. System.debug('createdDate ' + createdDate); System.debug('completedDate ' + completedDate); Long businessMillis = BusinessHours.diff(bhId, createdDate, completedDate); //Convert milliseconds to hours System.debug('businessMillis ' + businessMillis); Integer bHours = (Integer)((businessMillis/1000)/60)/60; System.debug('bHours ' + bHours); return bHours; }And the data from the BusinessHours database table:
Method
BusinessHours.diff()is calculating the Saturday and Sunday such as 24 hours working days!
How do I change Saturday and Sunday to be non-working days, hence zero working hours?
-
- sfadm sfadm
- September 26, 2017
- Like
- 0
- Continue reading or reply
SOQL query to retrieve files for cases
I want to find all case parent record id which contains the files
-
- divya1234
- July 28, 2017
- Like
- 0
- Continue reading or reply
Fetch Data from object between different date range in single query
I need to query a Custom object that has a relationship with Account (Account is Parent).
I have a requirement where I need to fetch all data from custom object where the set of Id will be of Account, and for each account the dateframe is different for each custom object.
EG: For Account 1 I have to fetch all data from custom object where the created date is within 10/03/2019 to 20/03/2019
For Account 2 I have to fetch all data from custom object where the created date is within 18/02/2019 to 25/02/2019
There can be many account and different date range.
So I have taken this solution, put all the account Id in one set and calculate the greatest and oldest date from all date timeframe then fetch the data from custom object then again using for loop get the exact data that is needed.
Is there any better solution to do this other than mentioned above. Please provide the details.
Thanks
Preyanka
I have a requirement where I need to fetch all data from custom object where the set of Id will be of Account, and for each account the dateframe is different for each custom object.
EG: For Account 1 I have to fetch all data from custom object where the created date is within 10/03/2019 to 20/03/2019
For Account 2 I have to fetch all data from custom object where the created date is within 18/02/2019 to 25/02/2019
There can be many account and different date range.
So I have taken this solution, put all the account Id in one set and calculate the greatest and oldest date from all date timeframe then fetch the data from custom object then again using for loop get the exact data that is needed.
Is there any better solution to do this other than mentioned above. Please provide the details.
Thanks
Preyanka
-
- Preyanka
- April 20, 2019
- Like
- 0
- Continue reading or reply
Einstein voice
Hello All,
Is there any documentation on how to implement or know more about Einstein voice.
Thanks
Is there any documentation on how to implement or know more about Einstein voice.
Thanks
-
- Preyanka
- November 14, 2018
- Like
- 0
- Continue reading or reply
How to connect different org in Environment hub
Hello ,
I am new to environment hub. I have created a development edition org(Free) and Enterprise Edition org (Trial) from Environment hub. Now I wanted to migrate my code form developer edition org to Enterprise edition org via change set. But in deployment settings when I try to create a connection it is not provided any link.
Hence my question is, is it possible to create connection between those two org. please provide some explanation.
Thanks
I am new to environment hub. I have created a development edition org(Free) and Enterprise Edition org (Trial) from Environment hub. Now I wanted to migrate my code form developer edition org to Enterprise edition org via change set. But in deployment settings when I try to create a connection it is not provided any link.
Hence my question is, is it possible to create connection between those two org. please provide some explanation.
Thanks
-
- Preyanka
- May 21, 2018
- Like
- 0
- Continue reading or reply
Change font and size of slds tab
Hello,
I am using visualforce page and using slds to get the tab view. but the tab label comes in Caps and I can not change the font and size of tab label.
I am using exactly the same code present in SLDS tab page(https://www.lightningdesignsystem.com/components/tabs/#site-main-content)

I want to reduce the size, change the font and wanted to view it like Item One.
Please help me on this.
Thanks
Preyanka
I am using visualforce page and using slds to get the tab view. but the tab label comes in Caps and I can not change the font and size of tab label.
I am using exactly the same code present in SLDS tab page(https://www.lightningdesignsystem.com/components/tabs/#site-main-content)
I want to reduce the size, change the font and wanted to view it like Item One.
Please help me on this.
Thanks
Preyanka
-
- Preyanka
- May 18, 2018
- Like
- 0
- Continue reading or reply
Pass field value from parent page to modal using slds
Hi,
I am using visualforce page(not lightning component) and in the page I use slds modal. When I click a button in the page it will open the modal above the page and the parent page greyed out. I want to pass some field values of parent page to modal. Can any one help how to do that. Modal is working fine but want a idea to pass value to modal.
<apex:slds /> <script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
<!--Button-->
<button class="slds-button slds-button--brand" id="toggleBtn" onclick="openModal(); return false;">Find</button>
<div class="search">
<div class="slds-modal" aria-hidden="true" role="dialog" id="modal">
<div class="slds-modal__container">
<header class="slds-modal__header">
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Search</h2>
</header>
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<div class="modal-body" id="modBody">
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<tr>
<td>
Zip code:
</td>
<td>
<apex:inputText value="{!inputZipCode}" id="txtZipCode" maxlength="9" />
</td>
</tr>
</table>
</div>
</div>
<footer class="slds-modal__footer">
<button class="slds-button slds-button_neutral" onclick="closeModal()">Cancel</button>
<apex:commandButton value="Search" reRender="modResult, modres" />
</footer>
</div>
</div>
<div class="slds-backdrop" id="backdrop"></div>
</div>
<!-- Modal Toggle Script -->
<script>
j$ = jQuery.noConflict();
//Modal Open
function openModal(){
j$('#backdrop').addClass('slds-backdrop--open');
j$('#modal').addClass('slds-fade-in-open');
}
//Modal Close
function closeModal(){
j$('#modal').removeClass('slds-fade-in-open');
j$('#backdrop').removeClass('slds-backdrop--open');
}
</script>
I am using visualforce page(not lightning component) and in the page I use slds modal. When I click a button in the page it will open the modal above the page and the parent page greyed out. I want to pass some field values of parent page to modal. Can any one help how to do that. Modal is working fine but want a idea to pass value to modal.
<apex:slds /> <script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
<!--Button-->
<button class="slds-button slds-button--brand" id="toggleBtn" onclick="openModal(); return false;">Find</button>
<div class="search">
<div class="slds-modal" aria-hidden="true" role="dialog" id="modal">
<div class="slds-modal__container">
<header class="slds-modal__header">
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Search</h2>
</header>
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<div class="modal-body" id="modBody">
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<tr>
<td>
Zip code:
</td>
<td>
<apex:inputText value="{!inputZipCode}" id="txtZipCode" maxlength="9" />
</td>
</tr>
</table>
</div>
</div>
<footer class="slds-modal__footer">
<button class="slds-button slds-button_neutral" onclick="closeModal()">Cancel</button>
<apex:commandButton value="Search" reRender="modResult, modres" />
</footer>
</div>
</div>
<div class="slds-backdrop" id="backdrop"></div>
</div>
<!-- Modal Toggle Script -->
<script>
j$ = jQuery.noConflict();
//Modal Open
function openModal(){
j$('#backdrop').addClass('slds-backdrop--open');
j$('#modal').addClass('slds-fade-in-open');
}
//Modal Close
function closeModal(){
j$('#modal').removeClass('slds-fade-in-open');
j$('#backdrop').removeClass('slds-backdrop--open');
}
</script>
-
- Preyanka
- October 12, 2017
- Like
- 0
- Continue reading or reply
onchange event not working for dependent picklist
Hi All,
I am facing problem with onchange event of <apex:inputfield> that actually calls <apex:actionFunction>
The problem is I have a depenedent picklist. When I choose value in controlling picklist the dependent picklist will enabled and values will be rendered. When there is more than one value in the dependent picklist there is no problem with the onchange event but when there is only one value, as per dependent picklist behaviour, that value was selected by default at that time onchange event is not working.
There is one solution to use javascript and add a dummy value like --select-- in the picklist but is there any other option, hence user do not have to select the dependent picklist value if there is only one value.
I am facing problem with onchange event of <apex:inputfield> that actually calls <apex:actionFunction>
The problem is I have a depenedent picklist. When I choose value in controlling picklist the dependent picklist will enabled and values will be rendered. When there is more than one value in the dependent picklist there is no problem with the onchange event but when there is only one value, as per dependent picklist behaviour, that value was selected by default at that time onchange event is not working.
There is one solution to use javascript and add a dummy value like --select-- in the picklist but is there any other option, hence user do not have to select the dependent picklist value if there is only one value.
-
- Preyanka
- April 16, 2017
- Like
- 0
- Continue reading or reply
How to view what webservice is present in managed package
Hi,
I have managed package installed in ord and accessing the web service from mobile app.
As I am new to managed package hence could someone help on below queries:
So from where we can check that what type of web service is used, what are method or input/output of the web service method.
Can we able to download the wsdl from managed package?
Thanks
Preyanka
I have managed package installed in ord and accessing the web service from mobile app.
As I am new to managed package hence could someone help on below queries:
So from where we can check that what type of web service is used, what are method or input/output of the web service method.
Can we able to download the wsdl from managed package?
Thanks
Preyanka
-
- Preyanka
- March 14, 2017
- Like
- 0
- Continue reading or reply
How many times we can reschedule a certification exam
Hi,
Can any one please help me on this :
How many times we can reschedule a certification exam? Is there any limit or we can reschedule it many times?
Thanks
Can any one please help me on this :
How many times we can reschedule a certification exam? Is there any limit or we can reschedule it many times?
Thanks
-
- Preyanka
- February 14, 2017
- Like
- 0
- Continue reading or reply
Can we edit standard salesforce report
Hello,
It is really helpful if someone clarifies below scenario:
1. Can we edit standard salesforce report.
2. Can we add bucket filter, field filter in standard report?
As per my understanding while we try to edit a standard report using customize button it will give us option to save the report in another name that is the clone of the standard report(we can refer it as custom report also) and the customization is not saved in the standard report. Please correct me if I am wrong.
Hence is there any another way to edit standard report.
Thanks
Preyanka
It is really helpful if someone clarifies below scenario:
1. Can we edit standard salesforce report.
2. Can we add bucket filter, field filter in standard report?
As per my understanding while we try to edit a standard report using customize button it will give us option to save the report in another name that is the clone of the standard report(we can refer it as custom report also) and the customization is not saved in the standard report. Please correct me if I am wrong.
Hence is there any another way to edit standard report.
Thanks
Preyanka
-
- Preyanka
- February 08, 2017
- Like
- 0
- Continue reading or reply
It is possible for a user to own a record and not see it
Hi,
It is really helpful if someone clarifies the below scenario:
Is it possible for a user to own a record and not see it? Because it seems that a user need atleast read permission to own a record. If the user does not have that permission either through profile/permission set then he/she will not able to view the record and if we try to assign the record manually to them then we will get the error message “TRANSFER_REQUIRES_READ”.
But if the owner assignment is done through assignment rule/ workflow rule the scenario is possible and I just want to know how?
Thanks in advance
It is really helpful if someone clarifies the below scenario:
Is it possible for a user to own a record and not see it? Because it seems that a user need atleast read permission to own a record. If the user does not have that permission either through profile/permission set then he/she will not able to view the record and if we try to assign the record manually to them then we will get the error message “TRANSFER_REQUIRES_READ”.
But if the owner assignment is done through assignment rule/ workflow rule the scenario is possible and I just want to know how?
Thanks in advance
-
- Preyanka
- August 19, 2016
- Like
- 0
- Continue reading or reply
Assign value to array
Hi
I am facing issue while try to assign a value in an array that was declared in WSDL2Apex class. The array was declare like below in WSDL2Apex class
public testtempuriOrg.question[] question;
where question is another class and have some string variable declared. But when i try to assign the question value in testtempuriOrg.question[] from another class I get the error message "System.NullPointerException: Attempt to de-reference a null object"
Please help want need to do...
Thanks
I am facing issue while try to assign a value in an array that was declared in WSDL2Apex class. The array was declare like below in WSDL2Apex class
public testtempuriOrg.question[] question;
where question is another class and have some string variable declared. But when i try to assign the question value in testtempuriOrg.question[] from another class I get the error message "System.NullPointerException: Attempt to de-reference a null object"
Please help want need to do...
Thanks
-
- Preyanka
- August 04, 2016
- Like
- 0
- Continue reading or reply
How to edit User object field 'Admin Info Emails' ?
User objet in salesforce has a field 'Admin Info Emails'. This field is checkbox. In our org, the users of same profile(customer service profile), this field has different status for different users(of same profile). How to edit this button?
Thanks in advance
Thanks in advance
- Pradnya79
- August 08, 2018
- Like
- 0
- Continue reading or reply
Which three declarative fields are correctly mapped to variable types in Apex.
Which three declarative fields are correctly mapped to variable types in Apex?
Choose 3 answers.
A. Checkbox maps to Boolean
B. Number maps to Integer
C. Date/Time maps to Datetime
D. TextArea maps to List of type String
E. Number maps to Decimal
Choose 3 answers.
A. Checkbox maps to Boolean
B. Number maps to Integer
C. Date/Time maps to Datetime
D. TextArea maps to List of type String
E. Number maps to Decimal
- VJay
- August 07, 2018
- Like
- 1
- Continue reading or reply
How to migrate library contents from one salesforce org to another salesforce org?
I want to migrate library contents from one salesforce org to another salesforce org.
I was able to do it using data loader and making local copies of content.
This is good for less number of contents but not good for large number of contents as it requires manual intervention.
Please suggest some automatic easy-to-use way to do this.
I was able to do it using data loader and making local copies of content.
This is good for less number of contents but not good for large number of contents as it requires manual intervention.
Please suggest some automatic easy-to-use way to do this.
- Devendra Deshpande 22
- August 07, 2018
- Like
- 0
- Continue reading or reply
how to write test class for consuming Third party rest API integration class
Hi Please help write test class and get code coverage for my class
Class:-
public class IssuersCalloutController{
public IssuersCalloutController(ApexPages.StandardController controller) {
}
public PageReference saveCalloutResult(){
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://test/getIssueList');
req.setMethod('GET');
req.setHeader('Content-Type', 'application/json');
req.setHeader('Accept','application/json');
system.debug('request endpoint '+ req);
String username = 'amit';
String password = 'password';
Blob headerValue= Blob.valueOf(username + ':' + password);
system.debug('headerValue'+ headerValue);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setTimeout(60000);
system.debug('###req### '+ req);
HttpResponse res = h.send(req);
system.debug('###res### '+ res);
string response = res.getBody();
system.debug('response'+ response);
Set<String> bankNames = New Set<String>();
// declare issuer list to inser
List<Issuers__c> InsertedIssuers = New List<Issuers__c>();
// I used limit in below query, but its better to use any filter to limit the data
for(Issuers__c issuer : [Select Id,Bankdir_Name__c from Issuers__c LIMIT 50000]){
If(!string.isBlank(issuer.Bankdir_Name__c)){
bankNames.add(issuer.Bankdir_Name__c);
//system.debug('###Bank Name### '+ bankNames);
//system.debug('issuerbankdir'+ issuer.Bankdir_Name__c);
}
}
system.debug('###Bank Name### '+ bankNames.size());
List<JsonParserDetail> responseDetails = JsonParserDetail.parse(response);
system.debug('****responseDetails****** '+responseDetails);
if(responseDetails.size() > 0){
for(JsonParserDetail jpd : responseDetails){
If(!bankNames.contains(jpd.issuerBankdirName)){
InsertedIssuers.add(getIssuer(jpd.issuername,jpd.issuerBankdirName,jpd.processorName,jpd.subProcessorName,jpd.siloName));
}
}
}
If(InsertedIssuers.size() >0){
insert InsertedIssuers;
}
PageReference p = apexPages.currentPage();
ApexPages.Message msg=new ApexPages.Message(ApexPages.Severity.CONFIRM,'Preview 2 list Successfully updated'+InsertedIssuers.size()+'"Thank you!');
ApexPages.addMessage(msg);
return p;
}
public Issuers__c getIssuer(string iName, string ibName, string pName, string spName,string siloName){
Issuers__c issuer = New Issuers__c();
issuer.Name = iName;
issuer.Bankdir_Name__c = ibName;
issuer.Processor_Name__c = pName;
issuer.SubProcessor_Name__c = spName;
issuer.Silo_Name__c = siloName;
return issuer;
}
}
Thanks
Class:-
public class IssuersCalloutController{
public IssuersCalloutController(ApexPages.StandardController controller) {
}
public PageReference saveCalloutResult(){
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://test/getIssueList');
req.setMethod('GET');
req.setHeader('Content-Type', 'application/json');
req.setHeader('Accept','application/json');
system.debug('request endpoint '+ req);
String username = 'amit';
String password = 'password';
Blob headerValue= Blob.valueOf(username + ':' + password);
system.debug('headerValue'+ headerValue);
String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
req.setHeader('Authorization', authorizationHeader);
req.setTimeout(60000);
system.debug('###req### '+ req);
HttpResponse res = h.send(req);
system.debug('###res### '+ res);
string response = res.getBody();
system.debug('response'+ response);
Set<String> bankNames = New Set<String>();
// declare issuer list to inser
List<Issuers__c> InsertedIssuers = New List<Issuers__c>();
// I used limit in below query, but its better to use any filter to limit the data
for(Issuers__c issuer : [Select Id,Bankdir_Name__c from Issuers__c LIMIT 50000]){
If(!string.isBlank(issuer.Bankdir_Name__c)){
bankNames.add(issuer.Bankdir_Name__c);
//system.debug('###Bank Name### '+ bankNames);
//system.debug('issuerbankdir'+ issuer.Bankdir_Name__c);
}
}
system.debug('###Bank Name### '+ bankNames.size());
List<JsonParserDetail> responseDetails = JsonParserDetail.parse(response);
system.debug('****responseDetails****** '+responseDetails);
if(responseDetails.size() > 0){
for(JsonParserDetail jpd : responseDetails){
If(!bankNames.contains(jpd.issuerBankdirName)){
InsertedIssuers.add(getIssuer(jpd.issuername,jpd.issuerBankdirName,jpd.processorName,jpd.subProcessorName,jpd.siloName));
}
}
}
If(InsertedIssuers.size() >0){
insert InsertedIssuers;
}
PageReference p = apexPages.currentPage();
ApexPages.Message msg=new ApexPages.Message(ApexPages.Severity.CONFIRM,'Preview 2 list Successfully updated'+InsertedIssuers.size()+'"Thank you!');
ApexPages.addMessage(msg);
return p;
}
public Issuers__c getIssuer(string iName, string ibName, string pName, string spName,string siloName){
Issuers__c issuer = New Issuers__c();
issuer.Name = iName;
issuer.Bankdir_Name__c = ibName;
issuer.Processor_Name__c = pName;
issuer.SubProcessor_Name__c = spName;
issuer.Silo_Name__c = siloName;
return issuer;
}
}
Thanks
- Amit Kr Singh
- August 07, 2018
- Like
- 0
- Continue reading or reply
clone recursion
I needed a trigger to create clone of account record on insert.
To avoid recursion I have used a boolean. Is there any method to stop recursion that can be used in this place.
-------------------------------------------------------------------------------------
public class CloneAccountTriggerHandler {
public static Boolean cloneRecord = true;
/**
Method : cloneAccountRecord
Type : Test Method
Description : Method To create Clone of Account Record when inserted
*/
public static List<Account> cloneAccountRecord(List<Account> newAccount){
List<Account> listAccount = new List<Account>();
if(cloneRecord) {
System.debug(newAccount);
cloneRecord = false;
for(Account account : newAccount) {
listAccount.add(account.clone(false));
}
Database.insert(listAccount,false);
}
return listAccount;
}
}
To avoid recursion I have used a boolean. Is there any method to stop recursion that can be used in this place.
-------------------------------------------------------------------------------------
public class CloneAccountTriggerHandler {
public static Boolean cloneRecord = true;
/**
Method : cloneAccountRecord
Type : Test Method
Description : Method To create Clone of Account Record when inserted
*/
public static List<Account> cloneAccountRecord(List<Account> newAccount){
List<Account> listAccount = new List<Account>();
if(cloneRecord) {
System.debug(newAccount);
cloneRecord = false;
for(Account account : newAccount) {
listAccount.add(account.clone(false));
}
Database.insert(listAccount,false);
}
return listAccount;
}
}
- aress
- August 07, 2018
- Like
- 0
- Continue reading or reply
Hi Community had written one trigger which displays the child record count(student object) on parent obect (Teacher) below.Code has no errors but output is not coming while inserting or deleting or updating records on child object(student)
trigger studentcount1 on Student__c (after insert,after update,after delete,after undelete) {
set<ID> parentID=new set<ID>();
List<Teacher__c> ParentQueryList=new list<Teacher__c>();
List<Teacher__c> ParentToupdate=new list<Teacher__c>();
If(Trigger.isinsert|| Trigger.isupdate||Trigger.isundelete)
{
for(student__c acc:Trigger.new)
{
if(acc.subject__r.id!=null)
{
parentID.add(acc.subject__r.id);
}
}
}
If(Trigger.isdelete){
for(student__c acc:Trigger.old)
{
if(acc.subject__r.id!=null)
{
parentID.add(acc.subject__r.id);
}
}
}
if(parentID.size()>0)
ParentQueryList=[select id,name,childcount__c,(select id,name,subject__c from students__r) from Teacher__c where ID in :parentID];
system.debug('ParentQueryList--->'+ParentQueryList);
for(Teacher__c tc:ParentQueryList)
{
tc.childcount__c=tc.students__r.size();
ParentToupdate.add(tc);
}
if(ParentToupdate.size()>0)
{
update ParentToupdate;
}
}
set<ID> parentID=new set<ID>();
List<Teacher__c> ParentQueryList=new list<Teacher__c>();
List<Teacher__c> ParentToupdate=new list<Teacher__c>();
If(Trigger.isinsert|| Trigger.isupdate||Trigger.isundelete)
{
for(student__c acc:Trigger.new)
{
if(acc.subject__r.id!=null)
{
parentID.add(acc.subject__r.id);
}
}
}
If(Trigger.isdelete){
for(student__c acc:Trigger.old)
{
if(acc.subject__r.id!=null)
{
parentID.add(acc.subject__r.id);
}
}
}
if(parentID.size()>0)
ParentQueryList=[select id,name,childcount__c,(select id,name,subject__c from students__r) from Teacher__c where ID in :parentID];
system.debug('ParentQueryList--->'+ParentQueryList);
for(Teacher__c tc:ParentQueryList)
{
tc.childcount__c=tc.students__r.size();
ParentToupdate.add(tc);
}
if(ParentToupdate.size()>0)
{
update ParentToupdate;
}
}
- Santhosh Kon 5
- August 07, 2018
- Like
- 0
- Continue reading or reply
Invalid Number Error
Hi guys,
I'm having a bit of a nightmare using data loader to mass upload records to a custom object. I have extracted data from one custom object and I'm uploading the data into another object.
The field is question is Quantity__c and both are of type number with a length of 18 and 0 decimal places. I have changed the format in the .csv file to reflect this but it just is not accepting the data.
Has anyone faced a similar issue and if so how did you resolve it?
I'm having a bit of a nightmare using data loader to mass upload records to a custom object. I have extracted data from one custom object and I'm uploading the data into another object.
The field is question is Quantity__c and both are of type number with a length of 18 and 0 decimal places. I have changed the format in the .csv file to reflect this but it just is not accepting the data.
Has anyone faced a similar issue and if so how did you resolve it?
- Nevin O'Regan 3
- August 06, 2018
- Like
- 0
- Continue reading or reply
Bulkify the before insert or update Triggers?
Hi Team,
How can we bulkify this using trigger handler class, please let me know any one.
Trigger :
---------------
I want to bulkify this code using trigger handler class.
Regards,
Lakshmi
How can we bulkify this using trigger handler class, please let me know any one.
Trigger :
---------------
trigger OpportunityTrig on Opportunity (before insert, before update, after insert, after update) { if(Trigger.isBefore && Trigger.isInsert){ for(opportunity op : Trigger.New){ //opportunity o = Trigger.oldmap.get(op.Id); if(op.Close_Deal_Date__c != null){ Integer y = op.Close_Deal_Date__c.YEAR(); Integer m = ((op.Close_Deal_Date__c.MONTH()-1)/3)+1; String q = String.valueOf(y)+' Q'+String.valueOf(m); system.debug('y'+y+' Mon :'+m+' Quarter:'+q); op.Reporting_Quarter__c = q; } else if(op.Close_Deal_Date__c == null){ op.Reporting_Quarter__c = null; } } } if(Trigger.isBefore && Trigger.isUpdate){ OpportunityTriggerHandlerCls.oppCategoryUpdate((List<Opportunity>)Trigger.New); for(opportunity op : Trigger.New){ opportunity o = Trigger.oldmap.get(op.Id); if(op.Close_Deal_Date__c != null && (op.Close_Deal_Date__c != o.Close_Deal_Date__c)){ Integer y = op.Close_Deal_Date__c.YEAR(); Integer m = ((op.Close_Deal_Date__c.MONTH()-1)/3)+1; String q = String.valueOf(y)+' Q'+String.valueOf(m); system.debug('y'+y+' Mon :'+m+' Quarter:'+q); op.Reporting_Quarter__c = q; } else if(op.Close_Deal_Date__c == null && (op.Close_Deal_Date__c != o.Close_Deal_Date__c)){ op.Reporting_Quarter__c = null; } } } }
I want to bulkify this code using trigger handler class.
Regards,
Lakshmi
- Lakshmi S
- August 06, 2018
- Like
- 0
- Continue reading or reply
unable to remove duplicate lastnames from contact
I have 10000 records in contact object and 5000 of them are duplicate contact lastname.
My requirement is to eliminate the duplicates lastnames in contact object.
I have soql script which unfortunately doesnt work.
List<Contact> conList=[select ID,LastName from contact LIMIT 50000];
Map<String,contact> conMap=new Map<String,Contact>();
for(Contact c:conList)
{
conMap.put(c.LastName,c);
}
//at this point the map should merge the duplicates. Please correct my understanding
Now datbase.update(conMap.values());
But once update statement is executed, the duplicate records still exists. Only the map has the updated records.
Please let me know if this approach is right....
thanks
sheila
My requirement is to eliminate the duplicates lastnames in contact object.
I have soql script which unfortunately doesnt work.
List<Contact> conList=[select ID,LastName from contact LIMIT 50000];
Map<String,contact> conMap=new Map<String,Contact>();
for(Contact c:conList)
{
conMap.put(c.LastName,c);
}
//at this point the map should merge the duplicates. Please correct my understanding
Now datbase.update(conMap.values());
But once update statement is executed, the duplicate records still exists. Only the map has the updated records.
Please let me know if this approach is right....
thanks
sheila
- sheila srivatsav
- August 06, 2018
- Like
- 0
- Continue reading or reply
Update custom fields on all child records when updation of same fields on that field on parent occurs. using trigger
I have 2 custom objects: Student and Registration.They have a same field class. Registration has a lookup to Student. I need to update all related registration records's class field when the class of student is updated using triggers. (A student can have multiple registrations)
Thanks in advance.
Thanks in advance.
- Kanishka Jaroli
- August 06, 2018
- Like
- 0
- Continue reading or reply
Third Lookup field to User on Contact not allowed
The Contact object already has two lookup fields to User: Created By and Owner. I would like to add a third that will be used to indicate responsibility for for marketing activities. In other words, a Contact will be owned by someone - someone who is a field based salesperson - yet will have someone who is assigned from the Inside Sales team to communicate with the Contact for other issues. Looks like I am unable to do that because adding the lookup would be a third lookup to the User object.
I can use a junction object but that will make things significantly more complicated. Does anyone have a workaround or idea to make this work? Am I missing something?
I can use a junction object but that will make things significantly more complicated. Does anyone have a workaround or idea to make this work? Am I missing something?
- Linked2Mark
- August 01, 2018
- Like
- 1
- Continue reading or reply
Pass field value from parent page to modal using slds
Hi,
I am using visualforce page(not lightning component) and in the page I use slds modal. When I click a button in the page it will open the modal above the page and the parent page greyed out. I want to pass some field values of parent page to modal. Can any one help how to do that. Modal is working fine but want a idea to pass value to modal.
<apex:slds /> <script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
<!--Button-->
<button class="slds-button slds-button--brand" id="toggleBtn" onclick="openModal(); return false;">Find</button>
<div class="search">
<div class="slds-modal" aria-hidden="true" role="dialog" id="modal">
<div class="slds-modal__container">
<header class="slds-modal__header">
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Search</h2>
</header>
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<div class="modal-body" id="modBody">
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<tr>
<td>
Zip code:
</td>
<td>
<apex:inputText value="{!inputZipCode}" id="txtZipCode" maxlength="9" />
</td>
</tr>
</table>
</div>
</div>
<footer class="slds-modal__footer">
<button class="slds-button slds-button_neutral" onclick="closeModal()">Cancel</button>
<apex:commandButton value="Search" reRender="modResult, modres" />
</footer>
</div>
</div>
<div class="slds-backdrop" id="backdrop"></div>
</div>
<!-- Modal Toggle Script -->
<script>
j$ = jQuery.noConflict();
//Modal Open
function openModal(){
j$('#backdrop').addClass('slds-backdrop--open');
j$('#modal').addClass('slds-fade-in-open');
}
//Modal Close
function closeModal(){
j$('#modal').removeClass('slds-fade-in-open');
j$('#backdrop').removeClass('slds-backdrop--open');
}
</script>
I am using visualforce page(not lightning component) and in the page I use slds modal. When I click a button in the page it will open the modal above the page and the parent page greyed out. I want to pass some field values of parent page to modal. Can any one help how to do that. Modal is working fine but want a idea to pass value to modal.
<apex:slds /> <script src="http://code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
<!--Button-->
<button class="slds-button slds-button--brand" id="toggleBtn" onclick="openModal(); return false;">Find</button>
<div class="search">
<div class="slds-modal" aria-hidden="true" role="dialog" id="modal">
<div class="slds-modal__container">
<header class="slds-modal__header">
<h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Search</h2>
</header>
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<div class="modal-body" id="modBody">
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<tr>
<td>
Zip code:
</td>
<td>
<apex:inputText value="{!inputZipCode}" id="txtZipCode" maxlength="9" />
</td>
</tr>
</table>
</div>
</div>
<footer class="slds-modal__footer">
<button class="slds-button slds-button_neutral" onclick="closeModal()">Cancel</button>
<apex:commandButton value="Search" reRender="modResult, modres" />
</footer>
</div>
</div>
<div class="slds-backdrop" id="backdrop"></div>
</div>
<!-- Modal Toggle Script -->
<script>
j$ = jQuery.noConflict();
//Modal Open
function openModal(){
j$('#backdrop').addClass('slds-backdrop--open');
j$('#modal').addClass('slds-fade-in-open');
}
//Modal Close
function closeModal(){
j$('#modal').removeClass('slds-fade-in-open');
j$('#backdrop').removeClass('slds-backdrop--open');
}
</script>
- Preyanka
- October 12, 2017
- Like
- 0
- Continue reading or reply
Days between two DateTime values excluding weekends
Hello,
I need to calculate hours between two DateTime objects in apex excluding non-working days and weekends. Here is my method:
// calculate working hours between createdDate and completedDate private Integer calculateWorkingHours(Datetime createdDate, Datetime completedDate) { List<BusinessHours> bhList = [Select id From BusinessHours Where IsDefault=true]; if(bhList.size() == 0) { //If there is a problem to get hours from the BusinessHours database table return -1 return -1; } // Get id of used set of business hours String bhId = bhList.get(0).id; // Returns the difference in milliseconds between a start and end Datetime based on a specific set of business hours. System.debug('createdDate ' + createdDate); System.debug('completedDate ' + completedDate); Long businessMillis = BusinessHours.diff(bhId, createdDate, completedDate); //Convert milliseconds to hours System.debug('businessMillis ' + businessMillis); Integer bHours = (Integer)((businessMillis/1000)/60)/60; System.debug('bHours ' + bHours); return bHours; }And the data from the BusinessHours database table:
Method
BusinessHours.diff()is calculating the Saturday and Sunday such as 24 hours working days!
How do I change Saturday and Sunday to be non-working days, hence zero working hours?
- sfadm sfadm
- September 26, 2017
- Like
- 0
- Continue reading or reply
Field is not writeable: Case.ContactMobile
trigger casePhone on Account (After insert,After update) {
for(Account a : trigger.new){
list<case> kca = New list<case>([select id,ContactMobile from case where ContactMobile != null And Accountid =: a.id]);
for(case ca : kca){
ca.ContactMobile = a.Phone;
}
}
}
for(Account a : trigger.new){
list<case> kca = New list<case>([select id,ContactMobile from case where ContactMobile != null And Accountid =: a.id]);
for(case ca : kca){
ca.ContactMobile = a.Phone;
}
}
}
- krishna23
- July 27, 2017
- Like
- 0
- Continue reading or reply
beginner sfdc apex not working
Hello all !
I am new to SFDC, so I could use some help
I have to custom objects
Product Move and Deliveries
I want a trigger that makes a delivery when I make an order
with the delivery named after my product move
trigger ProductMoveTrigger on Product_Move__c ( after insert) {
List<Delivery__c> deliveries= new List<Delivery__c>();
for(Product_Move__c c : Trigger.new)
{
Delivery__c d = new Delivery__c();
d.Name = c.Store__c + c.Product__c;
deliveries.add(d);
}
try {
insert deliveries;
} catch (system.Dmlexception e) {
system.debug (e);
}
}
where am I going wrong?
Thanks for the help
I am new to SFDC, so I could use some help
I have to custom objects
Product Move and Deliveries
I want a trigger that makes a delivery when I make an order
with the delivery named after my product move
trigger ProductMoveTrigger on Product_Move__c ( after insert) {
List<Delivery__c> deliveries= new List<Delivery__c>();
for(Product_Move__c c : Trigger.new)
{
Delivery__c d = new Delivery__c();
d.Name = c.Store__c + c.Product__c;
deliveries.add(d);
}
try {
insert deliveries;
} catch (system.Dmlexception e) {
system.debug (e);
}
}
where am I going wrong?
Thanks for the help
- Mark Fazekas
- July 27, 2017
- Like
- 0
- Continue reading or reply