• Cloudalyze
  • NEWBIE
  • 64 Points
  • Member since 2019

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 14
    Replies

Hi all,

I need to create an Opportunity when an Account picklist field is set on a specific value.

Let's call this picklist field: "Interest in our company"

When "Interest in our company" changes to " Yes " I need a process builder to create an Opportunity.

Have set this criteris in my process builder but the Opportunity is not created.

What am I doing wrong?

Kind regards,
Alfredo

@isTest
private class NumberOfEmailsSchedulableTest {
    
    public static final Integer numberOfAcc = 5;
    public static final Integer numberOfCon = 2;


    static testmethod void schedulerTest() 
       {
               CreateTestAccountsContactsAndTasks(numberOfAcc, numberOfCon);
               
               List<Task> tasks = [SELECT id, subject, ActivityDate, Sequence_Name__c FROM Task];



           String CRON_EXP = '0 0 0 15 3 ? *';
           
           // Create your test data
           Account acc = new Account();
           acc.name= 'test';
           insert
            acc;
           
           Test.startTest();

               String jobId = System.schedule('ScheduleApexClassTest',  CRON_EXP, new NumberOfEmailsSchedulable());
               CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
               System.assertEquals(CRON_EXP, ct.CronExpression);
               System.assertEquals(0, ct.TimesTriggered);

           Test.stopTest();
           // Add assert here to validate result
       }


       public static void CreateTestAccountsContactsAndTasks(Integer numOfAccounts, Integer contactsPerAccount)
        {

            Database.DMLOptions dml = new Database.DMLOptions(); 
            dml.DuplicateRuleHeader.allowSave = true;

          List<Account> accounts = new List<Account>();

          for(Integer i = 0; i < numOfAccounts; i++)
            {
            // create new account
                  Account newAccount = new Account(
                      Name         = 'Test' + String.valueOf(i),
                      Industry       = 'Accounting',
                      of_Locations__c = 5 + i,
                    sdr_owner__c = userinfo.getuserid()
                  );

                accounts.add(newAccount);
          }

          Database.insert(accounts, dml);

            List<Contact> contacts = new List<Contact>();

          for(Account act: accounts){
              for(Integer i = 0; i < contactsPerAccount; i++)
              {
                // create new contact
                 Contact con = new Contact(
                    LastName   = 'Test',
                    AccountId   = act.id,
                    Outreach_Status__c = 'In Contact',
                    Title     = 'Test' + String.valueOf(i),
                    Email     = 'test@test.com'
                  );

                  contacts.add(con);
              }
          }

           Database.insert(contacts, dml);

           List<Task> tasksToInsert = new List<Task>();

           for(Contact con : contacts)
           {
                   Task regularTask = new Task(
                       whoid = con.Id,
                       ActivityDate = Date.today(),
                       Status = 'Completed'
                   );
                   Task personalizedTask = new Task(
                       Sequence_Name__c = 'personalized',
                       whoid = con.Id,
                       ActivityDate = Date.today(),
                       Status = 'Completed'
                   );
                   Task sequencedTask = new Task(
                       Sequence_Name__c = 'WYWYN19',
                       whoid = con.Id,
                       ActivityDate = Date.today(),
                       Status = 'Completed'

                   );


                   tasksToInsert.add(regularTask);
                   tasksToInsert.add(personalizedTask);
                   tasksToInsert.add(sequencedTask);
           }

           Database.insert(tasksToInsert, dml);
        }

        public static User createUser(String username , String theAlias)
        {
          Integer randomInt = Integer.valueOf(math.rint(math.random()*1000));
            User u = new User
            (
               Alias = theAlias + String.valueOf(randomInt),
              Email = username + String.valueOf(randomInt)+ '@test.com',
            FirstName = 'Joe',
            LastName = username + String.valueOf(randomInt),
            TimeZoneSidKey = 'America/Los_Angeles',
            UserName = username + String.valueOf(randomInt) + '@test.com',
            LocaleSidKey = 'en_US',
            EmailEncodingKey = 'UTF-8',
            LanguageLocaleKey = 'en_US',
            ProfileID = UserInfo.getProfileId()
            );

            insert u;
            return u;
        }
    
}

I user database.Insert and no tasks appear. Why?
When client is open the New contact object then show Mailing country field is Required field with Red mark  manadatory.
  • March 18, 2019
  • Like
  • 0
I have a doubt appreciate if you could answer it. If both Permission Sets and Sharing Settings is used to open-up access over-riding OWD, what is the difference between Permission set and Sharing when functionality is same i.e to extend access to data and when do you use which feature. when 10 people have the same profile and only one user needs access to extra permission, I can create permission set, why not sharing rule? In which scenarios do you use Permission set and Sharing Settings please explain with examples.
Hi,

Is it possible to select parent values where the child field has a certain value?

For example:
 
Select Name
From Contract
Where Contract.Orders.Status = 'Draft'
I get the error: 

Didn't understand relationship 'Contracts' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.  Even if I add the __r to Orders though, I get the error...


 
  • March 13, 2019
  • Like
  • 0
hi everyone,


how to send a email with the trigger when a crcord is canclled included some filed with the record like name,address ?


Thanks 
AKLKK
 
  • March 08, 2019
  • Like
  • 0
Hi

I would like to update the opportunity stage to "transacting" when a roll-up summary field on the account (Total Transaction) become =>2 which is getting information from bill object. I tied many ways but unable to change stage. 

I tried below ways none of them are working.
1) Roll up summary field won't trigger workflow and process builder
2) Created a checkbox on opp which turns "true" when total transaction meet criteria, But still won't change stage through Process Builder/workflow. 

Please help!!!

Hi all,

I need to create an Opportunity when an Account picklist field is set on a specific value.

Let's call this picklist field: "Interest in our company"

When "Interest in our company" changes to " Yes " I need a process builder to create an Opportunity.

Have set this criteris in my process builder but the Opportunity is not created.

What am I doing wrong?

Kind regards,
Alfredo

Hello All,

I want to create a autonumber field which follows alias of a user. If the user is changed the auto number must restart in Professional edition.
For example, there is an autonumber as  'AC/18-19/FEB/001' , if the user alias is DA then it must start series as  'DA/18-19/MAR/001' in professional edition. 

Thank you in advance!
I need help in below apex class which display user details related to zipcode/account number. The code coverage is 69% help me with this-

Public list<UserDetails> getDetails(list<string> teriNames){
        set<id> teryIds = new set<id>();
        Map<id,Territory2> territorMap = new Map<id,Territory2>();
        Map<id,id> UserterriMap = new Map<id,id>();
        if(!teriNames.isEmpty()){
            
            for(Territory2 t:[SELECT id,DeveloperName,Name,Territory_No__c FROM Territory2 where Name IN : teriNames]){
               
                teryIds.add(t.id);
                territorMap.put(t.id,t);   
            }
        }
        set<Id> userIds = new set<id>();
        if(!teryIds.isEMpty()){
            for(UserTerritory2Association  Usert:[SELECT id,UserId,Territory2Id FROM UserTerritory2Association where isActive=true  and territory2id IN : teryIds ]){
                userIds.add(Usert.UserId );
                UserterriMap.put(Usert.UserId ,Usert.Territory2Id);
                  
            } 
        }
        if(!userIds.isEmpty()){
            
            for(user u:[select id, name ,phone,email, Manager.Name, Manager.Email, Manager.Phone, Business_Unit__c from user where id IN : userIds and isactive= true ORDER BY Business_Unit__c]){
                //users.add(u);
               
                UserDetails ud = new UserDetails();
                ud.usr = u;
                if(UserterriMap.containskey(u.id)){
                    Id terrritoryId = UserterriMap.get(u.id); 
                    ud.teriName =  territorMap.get(terrritoryId).name;
                }
                udetails.add(ud); 
            } 
        }
 return udetails;  
    }
    public class UserDetails{
        public user usr{get;set;}
        public string teriName{get;set;}
    }
}
<td>
                                <ui:inputcheckbox updateOn="change" change="{!c.SaveChanges}" text="{!item.Id}" value="{!item.CSopke1__Complete__c}"/>
                            </td>
                            <td>
                                <ui:inputDate  updateOn="change" change="{!c.searchChange}" value="{!item.CSopke1__Date__c}" displayDatePicker="true" />
                            </td>
                            <td>
                                <ui:inputText updateOn="change" change="{!c.searchChange}" value="{!item.CSopke1__Notes__c}"/>
                            </td>
Helper.js
SaveChanegHelper: function (cmp, event, helper) {
        var action = cmp.get('c.updateProcess');
        var processId = event.getSource().get("v.text");
        var iscompleted = event.getSource().get('v.value');
        var FieldLabel = ???
how I can get to know which field was changed so that I need to pass this fieldApi to further Apex controller toupdate record accordingly.
 
Hello All,  I keep getting an error of Warning Incorrect parameter type for operator '>='. Expected Object, received Number .  My formula is

 IF(Account.Debt_total_c>=25600,"1","4")
I want to format the standard phone number field values. Example value should be 123-456-9876 when we enter as 1234569876 in the phone field? Is it possible?