• RD@SF
  • SMARTIE
  • 1104 Points
  • Member since 2016

  • Chatter
    Feed
  • 36
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 332
    Replies
I am trying to display a list of records that contain a keyword in my flow (variable assigned in the previous screen). I know that I need to use a Sobject Collection but I am unsure how to display those results. Can someone please help point me in the right direction?
Thanks!
Hello,

I have created a flow that is called from a custom button in a Case.  The flow creates a custom object ("Service Report") and populates specific fields from the case.  Everything is working correctly, except I would like the Service Report to remain open once created.  The current flow does everything behind the scenes.  There is a window that says the Flow has completed successfully, but ideally I would like to not see that screen and just have the actual Service Report be open when complete (for the user to edit and click "save")

In a previous instance, this was done with custom button with URL hacking to populate the fields.  In that instance the window remained open.  I am working to eliminate the URL hacks and move to Flow but would like the same behavior.

User-added image
User-added image
Thanks,
Steve
I need to update a record if it meets a certain criteria, and if all other object records created within the last three months don't meet this criteria. I want to do this declaritvely so I am trying to use a combination of process builder and flow.

The process builder evaluates the criteria of a particular record on creation and edit, if this criteria is met, it's then passed onto a flow.

Once in the flow I wish to query all BMCServiceDesk__Incident__c objects records where the COL_JIS_Caller_Email__c field matches the record that originally triggered the flow. And only display records where survey_sent__c = TRUE and CreatedDate = Last 3 months.

IF the query displays no records, I wish to update the original Incident that triggered the flow, with the value of true on Survey_Sent__c.

Unfortunately this is not working, is there anyone able to help me with flow, I am very new to this tool!

User-added imageUser-added imageUser-added imageUser-added imageUser-added image
Hi,

  I am getting error below error while creating a new contact it is not happening while updating the contact. 
There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger ContactTrigger caused an unexpected exception, contact your administrator: ContactTrigger: execution of AfterUpdate caused by: System.ListException: Duplicate id in list: 001W000000amehmIAA: ()".
 Below is the code it is working perfect for updating the contact during creating a new contact i am getting duplicate list Please suggest me how to 
 modify the code I have highted the code which is giving me the error. 

 Please suggest me how to remove duplicates 
Trigger
========

if (Trigger.isAfter) {
  if(trigger.isInsert){
     ContactCertificateRollupHandlerNew1.ProcessInsert(Trigger.new);
  } else if(trigger.isUpdate) {
    ContactCertificateRollupHandlerNew1.ProcessInsert(Trigger.new); 
  }
   
   
Helper Class
=============

public class ContactCertificateRollupHandlerNew1{
 
Public static Map<id,integer> NSEmap1;
Public static Map<id,integer> NSEmap2;

Public static Integer NSEint1 = 0;
Public static Integer NSEint2 = 0;

Public static List<account> NSE1_Update = new List<account>();
Public static List<account> NSE2_Update = new List<account>(); 
 
Public static map<id,account> NSE1_Update_Map = new map<id,account>();
Public static map<id,account> NSE2_Update_Map = new map<id,account>();
 
 public static void ProcessInsert (List<Contact> newCntLst){
   list<id> actidSet = new list<id>();
       
     for(Contact cont : newCntLst){
       actidSet.add(cont.AccountId);                                 
      }  
      
     ProcessUpdate(actidSet[0]); 
     //GetLastAccounts(actidSet[0]);   
 }
 
 
 public static void ProcessUpdate (Id AccountID){
     
    GetLastAccounts(AccountID);    
  }
     
     
  public static void GetLastAccounts (Id AccountID){    
   
    set<id> GetAllActID = new set<id>();
    
    GetAllActID = AccountHierarchyUtil.ChildToParnet(AccountID);
    GetAllActID = AccountHierarchyUtil.ParnetToChild(AccountID);
    
    List<Account> LastAct = [SELECT Id, name FROM Account where id in :GetAllActID];
  
    Account LastAccount  = LastAct[LastAct.size() - 1];   
    
    System.debug('LastAccount ID ' + LastAccount.id);
    System.debug('LastAccount Name ' + LastAccount.name);
    
     accountRollupUpdate(LastAccount.id);
   }
   
  
   public static void accountRollupUpdate(Id PAccountID) {
        
        Id accountId = PAccountID;
        
        NSEmap1 = new Map<id,integer>();
        NSEmap2 = new Map<id,integer>();

        ChildToParnet(accountId);


        if(NSEmap1.size()>0){
    
            For(Id i : NSEmap1.keyset()){        
                Account ains = new Account(); 
                ains.id = i;
        
                system.debug('Account' + i);       
                system.debug(NSEmap1.get(i));
        
                ains.NSE_1_Status__c = NSEmap1.get(i);
                   NSE1_Update.add(ains);                      
            }
        }


       if(NSEmap2.size()>0){
    
           For(Id i : NSEmap2.keyset()){        
               Account ains = new Account();        
               ains.id = i;
        
              system.debug('Account' + i);        
              system.debug(NSEmap2.get(i));
        
              ains.NSE_2_Status__c = NSEmap2.get(i);        
                NSE2_Update.add(ains);
               
        
    }
    
}

        if(NSE1_Update.size()>0)   //These are line where the i am getting duplicate error while inserting
          
          update NSE1_Update;


        if(NSE2_Update.size()>0)
        
          update NSE2_Update;  
            
          /* map<id,account> nse1map = new map<id,account>();
            nse1map.putall(NSE1_Update);
        
            if(nse1map.size()>0){
            update nse1map.values();         
            }
            
            map<id,account> nse2map = new map<id,account>();
            nse2map.putall(NSE2_Update);
        
            if(nse2map.size()>0){
            update nse2map.values();
            }    */        
            
        
   }



public static void ChildToParnet (Id ChildId){
     
    For(Account acc : [select id,name, parentid, (Select id,NSE_1__c,NSE_2__c from contacts)from account where id =: ChildId]){
        
        For(Contact c : acc.contacts ){
            
            if(c.NSE_1__c == true)               
                 NSEint1 = NSEint1 +1;                
                 
            
            if(c.NSE_2__c == true)
                NSEint2 = NSEint2 + 1;                          
                            
            
        }
           NSEmap1.put(acc.id,NSEint1);
           NSEmap2.put(acc.id,NSEint2);  
        
        if(acc.parentid != null)            
           childToParnet(acc.parentid);
        
     }
  }
  
  }
  
Helper Class
=============

public class AccountHierarchyUtil{
    
    
    public static set<id> ChildToParnet (Id PAccountID){
        
        set<id> setactid = new set<id>();
        
        Id accountId = PAccountID;
        
        Account[] allparents = new Account[] {};
            
            Set<Id> parentIds = new Set<Id>{accountId};
                
                Account[] parent;
        
        do {
            
            parent = [select Id,ParentId, Name from Account where Id in :parentIds];
            
            allparents.addAll(parent);
            
            parentIds.clear();
            
            for (Account par : parent) 
                
                parentIds.add(par.ParentId);
            
        } while (parent.size() > 0);
        
        list<Account> Act = [select id, name from account where id in :allparents];
        
        for(Account A : Act){
            
            system.debug('Parent Accounts ' + a.name);  
            setactid.add(a.id);
            
        }      
        
        return setactid;
        
    }
    
    public static set<id> ParnetToChild (Id PAccountID){
        
        set<id> setactid = new set<id>();
        
        Id accountId = PAccountID;
        
        Account[] allChildren = new Account[] {};
            
            Set<Id> parentIds = new Set<Id>{accountId};
                
                Account[] children;
        
        do {
            
            children = [select Id, Name from Account where ParentId in :parentIds];
            
            allChildren.addAll(children);
            
            parentIds.clear();
            
            for (Account child : children) 
                
                parentIds.add(child.Id);
            
        } while (children.size() > 0);
        
        list<Account> Act = [select id, name from account where id in :allChildren];
        
        for(Account A : Act){
            
            system.debug('Child Accounts ' + a.name);  
            setactid.add(a.id);      
            
        }
        return setactid;
    }  
    
    
}

Thanks
Sudhir
  • December 04, 2017
  • Like
  • 0
here is the class:
 
global class Batch_EmailCheckLastModified implements Database.Batchable<sObject>{
    private String query;
    global Batch_EmailCheckLastModified(){
        System.debug('enter batch'); 
        this.query = 'SELECT Id,CreatedDate,LastModifiedDate,Expire_date__c,owner.name,owner.email,Quotation_Number__c, Inactive__c,PO_Approve_by_manager__c FROM Opportunity';
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        System.debug('starting'); 
        return Database.getQueryLocator(this.query);
    }
    
    global void execute(Database.BatchableContext BC, List<sObject> scope){
        List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
        for(SObject s:scope){
            Opportunity opp=(Opportunity)s;
            Date created = date.newInstance(opp.CreatedDate.year(),opp.CreatedDate.month(),opp.CreatedDate.day());
            Date LastModify = date.newInstance(opp.LastModifiedDate.year(),opp.LastModifiedDate.month(),opp.LastModifiedDate.day());
            Date todayDate = date.today();
            Integer dayBetweenCreated=created.daysbetween(todayDate);
            if((dayBetweenCreated>3)&&(created.isSameDay(LastModify))){
                 mails.add(sendAlertEmail(opp)); 
            }
                
        }
        send(mails);
        
    }
    
    global void finish(Database.BatchableContext BC){
        
    }
   private Messaging.Singleemailmessage sendAlertEmail(Opportunity quot) {
        EmailTemplate emailTemplate = getEmailTemplate();
        String[] userEmails = new List<String>();
        String Body = emailTemplate.Body;
        String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm() +
            '/' + quot.id; 
      
        Body = Body.replace('Dear User,', 'Dear User,<br/>');
        Body = Body.replace('Thank you,', '<br/><br/>Thank you,<br/>');
        Body = Body.replace('{!Opportunity.Link}', '<br/>'+fullFileURL);
        Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
        
        userEmails.add('warunya@crm-c.club');
        email.setHtmlBody(Body);
        email.setToAddresses(userEmails);
        email.setSubject(emailTemplate.Subject);
        
        //Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
        return email;
    }
    
    private void send(List<Messaging.SingleEmailMessage> mails){
        Messaging.sendEmail(mails);
    }
    
    private EmailTemplate getEmailTemplate() {
        EmailTemplate emailTemplate = [
            SELECT 
                Id, 
                HtmlValue,
                Subject,
                Body
            FROM EmailTemplate 
            Where Name = 'Update Opportunity Notification'
        ];
        return emailTemplate;
    }

}

And here is the test class:
 
@isTest (SeeAllData = true)
public class Test_Batch{
    static testMethod void Test_Batch_EmailCheckLastModifided_Method(){
        Test.startTest();
        
        Batch_EmailCheckLastModified batch = new Batch_EmailCheckLastModified();
        DataBase.executeBatch(batch);
        
        BatchOppProcuReserveExpiry batch2 = new BatchOppProcuReserveExpiry();
        Opportunity inputOpp=[select id,owner.name,Quotation_Number__c,owner.email from Opportunity limit 1];
        
        EmailTemplate newEmailTemplate = new EmailTemplate();
        newEmailTemplate.Name='Expired Opp';
        newEmailTemplate.DeveloperName='TestName';
        newEmailTemplate.TemplateType = 'Text';
		newEmailTemplate.FolderId = UserInfo.getUserId();
        newEmailTemplate.Body='{!Opportunity.OwnerFirstName} test {!Opportunity.Quotation_Number__c} test {!Opportunity.Link}';
        insert newEmailTemplate;
        batch2.sendAlertEmail(inputOpp);
        DataBase.executeBatch(batch2);

        Datetime dt = Datetime.now().addMinutes(1);
        String CRON_EXP = '0  00 1 3 * ?';
        
        System.schedule('Sample_Heading',CRON_EXP,new Schedule_EmailCheckLastModified()); 
        
        
        Test.stopTest();
        
    }
}

These two functions are not covered:
1- sendAlertEmail(Opportunity quot),
2- getEmailTemplate()

User-added image

I will appreciate any kind of help. Thank you
Attempting to create a Weekly Time Sheet system where users have to create Daily Time Card records. If there is a Daily Time Card detail record already created for that day on the Weekly TIme Sheet master record, is there a way to use a validation rule or perhaps a beforeinsert trigger to prevent a duplicate record from being created on the same day by that user? 
I am adding a validation rule for a large text area within the Flow Designer however the validation rule doesnt seem to be consistant in triggering.

This is my valiadation rule:

LEN (Comment) < 256

I am not sure how what is wrong with the validation rule
Hello,

i have custom VF-Page which works for "edit"-mode. But i need this one also for adding new data. 
 
<apex:page standardController="Contact" extensions="TestFriends" showHeader="true" sidebar="true">
    <apex:slds />
    <div class="slds-scope">
        <apex:detail subject="{!contact.Id}" relatedList="true" inlineEdit="true"/>
        <apex:form >

            <apex:pageBlock title="Friends" id="data0">
                <ul class="slds-list--horizontal slds-has-cards--space has-selections">
                    <apex:repeat value="{!friends}" var="eve" >
                        <br></br> 
                    <li class="slds-list__item">
                        <div class="slds-card">
                            
                        
                        <div class="slds-card__header">Friend</div>
                        <div class="slds-tile slds-tile--board">
                            <p class="slds-tile__title slds-truncate"> 
                                <apex:outputField label="Name:" value="{!eve.Name}" title="{!eve.Name}"/>
                            </p>
                            <p class="slds-tile__title slds-truncate"> 
                                <apex:outputField label="Gender" value="{!eve.Gender__c}" title="{!eve.Gender__c}"/>

                            </p> 
                        </div>
                            </div>
                    </li>
                    <apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton,cancelButton" hideOnEdit="editButton" />
                </apex:repeat>
            </ul>
            <apex:pageBlockButtons >
                        <apex:commandButton value="Edit" action="{!save}" id="editButton" />
                        <apex:commandButton value="Save" action="{!save}" id="saveButton" />
                        <apex:commandButton value="Cancel" action="{!cancel}" id="cancelButton" />
                        <apex:commandButton value="add row" action="{!addRowToTable}" id="addRowButton" reRender="data0" />
                    </apex:pageBlockButtons>
        </apex:pageBlock>
        
    </apex:form>
</div>
</apex:page>

Can anyone give an advise what i need to change?

thanks
Peter
Hi,
I have the below report requirement,
- Below is the ways my objects are related , which have taken in teh report.
"Contract" is related to "Claim",
Claim to Damage
Damage to Payment 

Now , i want a report of the records, where the Payment in Damage object is not present. I tried the below filter but its not giving the proper result, If anyone suggest plz, where i went wrong. Thnx

User-added image
Hi,

I want to attribute a specific user when creating a contract record in visual workflow.

Is it possible? I don't find the way.
Hi All,
Need a help on encrypted field identification, In my Org there are some Encrypted Fields on various objects.
Is there any ways to Identify All at once. see the below sample field for the same.
User-added image
With Regards,
Bheem
Trying to figure out how to count number of days and populate a field for "Date__C" calcualtion.  That part is easy.  But need it to count until ANOTHER date is entered then stop.

Assuming a workflow rule that can run the "counter" but then how to stop once second date is entered and be calculated upon.

(Date1__C) - TODAY()  - this runs and gives a running count  (X # of Days in number field) until below happens  

(Date1__C) - (Date2__D) which then produces (X # of Days in number field) and stops as the final date has been entered and reached.

Any ideas? And no not going ot get into the weekend days vs week days.  Thanks in advance!! 
We have an Almond and we plan to use as compliance training for new users. The new  user will see the training compliance. All new users will have a default profile "training-forcompliance" . Once he accepts it and acknwoledge by clicking on "true" button and clicks submit, his/her profile would automatically change and will change to the profile he or she should have. Is this possible? How can this be achieved? 
Thanks for your input
I have a problem with the following code:
<apex:page >
    
    <apex:form >
        <apex:commandButton value="Click" onclick="document.getElementById('sp').innerHTML='Hello'" />
<span id="sp"></span>
    </apex:form>

</apex:page>

When I click on the button the value I  am setting in the span tag ('Hello' in span)  appears for 1 second and again disappears, I want the text 'Hello' to remain in span after clicking on the button. Can somebody please help me with this?
Hi All,

So I have a picklist field containing several set of value.
One of the value is "PD - Chairman's Circle".

When a record is created through an apex code with this value, instead of using the same value, a new picklist value with exact name is created.
I wonder what causes this? Something to do with UTF-8 encoding?

 User-added image

Here is my apex code:

donationRecord.Donor_Tier__c = 'PD - ' + tokenWrapperInstance.category;
This a bit of a strage request so hopefully someone might be able to help!

I'm looking to put a component on the Homepage that will allow users to make a single selection from a list of multiple choices (be it from a drop-down menu or similar) in order to collect data from the types of calls they are getting. As such it needs to be something they can use many, many times a day so a normal poll is out of the question. It also needs to be something I can draw the information from afterwards via a report so I can collate the data over the weeks and months.

Would this be possible? And if not does anyone have any suggestions for something within Salesforce that could provide a similar service? 
Hello,

I have a custom object where an record can have child and in turn child can have one more child ,could any one help me with the logic to retrieve all the child records give the id of the parent record
Hi All

I have a scenario like 

If Active checkbox is checked on Class record then
Create 7 Child Future (Date >= today) coaching session records 
The Date range will determine the class date for Coaching Session record
The Date range will be generated from First Class Date field on the Class Record
For e.g. if an active Class record is created with a First Class Date of 1/9/2017
Then generate a date range with +7 days from this date
So the date range will be 1/9/2017 to 1/16/2017
Loop through this date range 
check if the date is in future
if yes then create a Coaching Session Record with class id pointing to the newly created or update class
1. I want to generate a receipt into excel by clicking a "generate reciept" button on a custom object
2. I want a second button "send email" to send an email from a custom object. The email will be sent using email template I created. 

Any ideas?
I'm trying to create a validation rule in order to get an error message if at least one of my all picklists' is blank. I tried to create it with AND() connector instead of the fact that this connector only support two conditions :
 
AND(AND(AND(ISPICKVAL( Visite_Effectu_e__c ,"Oui"),ISBLANK( Dur_e_Visite_Minutes__c )),ISBLANK( Interlocuteur_Pr_nom_Nom_1_del__c)),AND(AND(ISPICKVAL(Fonction_1__c ,""),ISPICKVAL( Pr_sence_d_un_rayon_libre_acc_s__c,"")),ISPICKVAL( Pr_sence_borne_anti_vol__c ,"")))
The logic behind this formula is :
 
AND ( AND ( AND (A,B) , C ), AND ( AND (D,E) , F ) )
If one of A, B, C, D, E or F picklists' is blank, you can't end the report and get an error.

If it's not clear, i can re-explain my problem or my formula ! 

Thank you for your help ! 
 
I would like to build a query where i can combine the follwoing three in to on query that is used for  record types prospect and member. any advice?

AND(
(RecordType.Name = "Prospect"),
OR(
ISBLANK( PersonMailingCity),
ISBLANK( PersonMailingStreet ),
ISBLANK( PersonMailingPostalCode )),
(NOT($User.BypassVR__c) && 
 
NOT( OR( ISBLANK(Phone ), REGEX( Phone ,"(\\D?[0-9]{3}\\D?)[\\s][0-9]{3}-[0-9]{4}"))))
 
NOT($User.BypassVR__c) && ($RecordType.Name = "Member" || $RecordType.Name = "Prospect") && ISBLANK( FirstName)
Hello,

I created a flow and a button to launch it.
The flow was debuged and works perfectly. But when I try to launch it using a custom button I receive an error:

"We can't launch this flow because of a variable error. Send this error message to your admin. The value 19/12/2019 is being provided for variable TermEndDate but isn't compatible with the variable's data type (Date)...
As you can see the value is Date type. I doubled checked that the field referenced is indeed Date type.

Can anyone please direct me to how to solve this?

Thanks,
Tal
I created a button "Send Email" that starts a Flow on an Opportunity. 

I created a Record Lookup element in the flow and created variables for the Opportunity field I want to capture. I created 30 variables.

Is there a way to display only the Opportunity fields that are ISBLANK on another Screen element? If yes, how would I accomplish this? Do I need to create a formula? I currently have 30 Opportunity fields I want to check. 

I created the Flow to ensure a user could check to see if they entered information in all fields.

Any help will be greatly appreciated. 

 

Hi there

I am looking to create a flow that updates a coupon code field with a coupon code based upon a sales price field.

There are 700 coupon codes and I need to create a formula or some flow that will update the coupon code field with the correct code based upon the value in the sales price field.

SAMPLE:

 Coupon value Coupon code
 £         100.00  u01ya
 £         110.00  qujrz
 £         120.00  44i77
 £         130.00  l4kua
 £         140.00  wdxk1
 £         150.00  5hotf

could someone help me with creating the formula logic to update a flow variable with the coupon code or advise on the best way to get this to work?  I tried process builder but it gets very flow and unusable as the size grows.
Hello,

I have a scenario, I have a parent object 'A' with fields DateTime, User(Lookup),Address and child object 'B' with same fields.
How to restrcit user to create only one record per day? User can create multiple records for the same parent for the same day.


Welcome to youe suggestions!

Thanks,
Nilesh
I have a visual flow where I am adding screen choice feilds together in a formula.  It allows me to add them together as long as the screen choices are answered in the flow. The flow skips questions depending on answers though.  How do I get a flow formula to add all of my screen choices together even if a screen choice is bypassed?
I am trying to display a list of records that contain a keyword in my flow (variable assigned in the previous screen). I know that I need to use a Sobject Collection but I am unsure how to display those results. Can someone please help point me in the right direction?
Thanks!
Hi
I have the following text field value in excel file:
20170320

I would like to convert it to a date field value when uploading files using Apex class & Visualforce Page:
03/20/2017

Thanks

 
Hi Everyone. I have a requirement where I need to use a Workflow time trigger to fire after 24 hours (1 day) of the criteria being met. But, this needs to consider Holidays and exclude them when executing the time trigger, for e.g. when the next day (since time trigger is set for 1 day, so next day) is a Holiday, it must fire after 2 days.

Note: We do not need to exclude weekends (Saturdays and Sundays) but only the Holidays must be excluded.

I have come accross some articles that talk about using a custom formula field and the time trigger to execute based on that formula field but most cases exclude weekends (which I do not want) as well and/or do not consider excluding Holidays.

Any ideas around how to acheive this will be largely helpful.

Thanks,
Sharique
Hi Folks,
I have created a Custom field(abc__c) in Case object. This field will have a unique value per case just like the Case ID.
I want to construct a URL which uses this custom field abc__C, and not the record id of the Case. When the user clicks on the URL the case record should open as per users permissions. 
I have a VF page. There is a Link called Add Contact on VF page. When user clicks on Add contact, it should redirected to standard contact form page,. Then user enter some data and clicks on save. When he clicks on save, it should return Recordid. How i can acieve this. Is there any possibilities. Please help me on this.
I need reccomendations and if possible price indication for someone to develop an Apex code to handle the above requirement