• kiranmutturu
  • PRO
  • 3752 Points
  • Member since 2011


  • Chatter
    Feed
  • 137
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 31
    Questions
  • 1345
    Replies
I have made lightningStyleSheet=true for my visualforce pages which are used in sites Community portal. I'm able to see lightning look and feel in SF org. How do i enable same lightning look and feel in Communty.
Hello awesome devs!

I am attempting to create a VF page with 4 fields for user inputting.  2 of these fields are Date fields which when filled in like MM/DD/YYY when I press the search button to call my custom controller the date in the field populated has its format changed to Tue Dec 26 00:00:00 GMT 2017 and doesnt seem to be being applied in the search itself as all records are returned and not ones just for the date entered. 

Can someone help me with gettign the format to stay as I think this is the cause of the date field not being used in the search criteria. 

Please see my VF Page and controller code below. 

Thank you very much for any help you can provide,

Shawn

VF Page Code - 
 
<apex:page controller="SubSearchController">
    
    <apex:form>
    	<apex:pageBlock id="pb">
        	<apex:pageBlockButtons>
                <apex:commandButton action="{!searchRecords}" value="Search" rerender="pb"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="2">
                <apex:outputLabel value="Account Id" />
                <apex:inputText value="{!AccId}"/>
                <apex:outputLabel value="Status" />
                <apex:inputText value="{!SubStatus}"/>
                <apex:outputLabel value="Service Activation date" />
                <apex:inputText value="{!SAD}"/>
                <apex:outputLabel value="Term End Date" />
                <apex:inputText value="{!TermEnd}"/>
            </apex:pageBlockSection>
            <apex:pageBlockTable var="record" value="{!records}" id="pbTable">
                <apex:column value="{!record.Name}" />
                <apex:column value="{!record.Zuora__Status__c}" />
                <apex:column value="{!record.Zuora__ServiceActivationDate__c}" />
                <apex:column value="{!record.Zuora__TermEndDate__c}" />
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
    
</apex:page>

Controller Code -

public class SubSearchController {

    public String AccId {get;set;}
    public String SubStatus {get;set;}
    public Date SAD {get;set;}
    public Date sadDate = Date.valueOf(SAD);
    public Date TermEnd {get;set;}
    public Date TermDate = Date.valueOf(TermEnd);
    
    public List<Zuora__Subscription__c> records {get; private set;}
    
    public SubSearchController(){
        records = new List<Zuora__Subscription__c>();   
    }
    
    public PageReference searchRecords() {
        
        records = [SELECT Zuora__Account__c, Zuora__Status__c, Zuora__ServiceActivationDate__c, Zuora__TermEndDate__c, OpportunityId__c, Total_Booking_Amount__c, Id, Name
                  FROM Zuora__Subscription__c WHERE Zuora__Account__c = : AccId AND Zuora__Status__c = : SubStatus AND (Zuora__ServiceActivationDate__c = : sadDate OR Zuora__TermEndDate__c = :TermDate)];
        return null;
        
    }
    
}

 
Hi All,

I am trying to complete the exercise where API name 'Trail__c' is required.

Create a custom object with 'Trail' as the Label and Object Name. The resulting API name will need to be 'Trail__c'.

It clearly mentions in the error  blank spaces or consecutive underscores not allowed. How do I achieve this? Thanks in advance.
public List<Account> Accountlist { get; set; }

public SelectOrganization(ApexPages.StandardSetController controller) {

    }

public List<Account> getAccounts() {
if(Accountlist == null) {
Accountlist = new List<Account>();
for(Account a: [select Id, Name from Account limit 25]) {

// As each Account is processed we create a new Account object and add it to the accountList
Accountlist.add(new Account(a));
}
 return Accountlist;

}


    }
Error:SObject constructor must use name=value pairs at line 16 column 17
Please help.
What needs to be done.
 

Hi Folks,
 

I did not set debug logs for an User but I want to find the operations performed by the User on a particuar day. Is is possible to query on all objects to find out what an user did on particular day?

Hi all,

I am going to create a package which consists apex classes, vf pages, custom settings, static resources.
now my question is i have created some custom labels and called in visual force pages, can i create package along with custom labels??

Thanks in advance.
 
hi,

I have a task like this..

User receives an Email with a link, When he/she clicks on the link it will redirect to page (Say HelloWorld)..

After entering details on that page and hit save, it should be (Helloworld page) converted as pdf and Saved to Purticular Custom Object (Say Yahoo) as Attachment.

Is there any ways to achieve it?

thanks
Hello everyone,

I have hit a wall and need help on how to test @future methods which are called from a trigger.

I think it has something do with the fact that @future methods are no necessarily processed immediately and as such my assertions are not passing, any help on how to get my code covered would be greatly appreciated,

What the trigger does is reassigns open and waiting cases to a queue when a user is disabled.

The trigger:
trigger user_deactivated_reassign_case on User (before update) {
    
    for(User u : trigger.new){
        User oldUsr = Trigger.oldMap.get(u.Id);
        if(oldUsr.IsActive==TRUE && u.IsActive==FALSE){
            User newUsr = Trigger.newMap.get(u.Id);
            string recordIds = u.Id;
            user_deactivation_reassign_case_class.reassign_case(recordIds);
        }
    }
}

The @future Apex Class:
public class user_deactivation_reassign_case_class {
    @future
    public static void reassign_case(string recordIds){
        List<Case> cas = [SELECT Id, Type FROM Case WHERE OwnerId=:recordIds];
        List<Case> casesTobeUpdated = new List<Case>();
               
        for(Case currentCase : cas){
            if(currentCase.Status=='Open'||currentCase.Status=='Waiting Response'||currentCase.Status=='On Hold'){
                if(currentCase.Type=='AU.COM'||currentCase.Type=='Customer Service'){
                    currentCase.OwnerId='00G90000001mq6F'; //Premium Support L2
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='Management'){
                    currentCase.OwnerId='00G90000001mq5m'; //Management
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='Administration'||currentCase.Type=='Domain Dispute'){
                    currentCase.OwnerId='00G90000001mq65'; //Premium Admin
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='EDU.AU'||currentCase.Type=='GOV.AU'||currentCase.Type=='Corporate'){
                    currentCase.OwnerId='00G90000001mzrl'; //Corporate
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='VPS Unmanaged'||currentCase.Type=='VPS Managed'){
                    currentCase.OwnerId='00G90000001nJfA'; //VPS Unmanaged
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='Sales'||currentCase.Type=='Social Media Sales'||currentCase.Type=='Online Marketing Sales'){
                    currentCase.OwnerId='00G90000001mzrH'; //Retail Sales
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='Online Marketing Support'){
                    currentCase.OwnerId='00G90000001mzrR'; //Online Marketing Support
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='Web Design'){
                    currentCase.OwnerId='00G90000001mzT4'; //Web Design
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='Website Security'){
                    currentCase.OwnerId='00G90000001nAl0'; //Website Security
                    casesTobeUpdated.add(currentCase);
                }
                else if(currentCase.Type=='Credit Control'){
                    currentCase.OwnerId='00G90000001nAlK'; //Credit Control
                    casesTobeUpdated.add(currentCase);
                }
                else{
                    currentCase.OwnerId='00G90000001mq6F'; //Premium Support L2
                    casesTobeUpdated.add(currentCase);
                }
            }
        }
    update casesTobeUpdated;
    }
}

And the test class which I can't figure out:
@isTest
public class user_deactivation_reassign_case_test {
    public static testmethod void test_user_termination(){
        User thisUser = [SELECT Id FROM USER WHERE Name='System Automation'];
        
        system.runAs(thisUser){
        User u = new User(FirstName='Test',
                          LastName='Test',
                          Username='apextest@netregistry.com', 
                          Email='apextest@netregistry.com', 
                          Alias='test', 
                          CommunityNickname='test', 
                          TimeZoneSidKey='Australia/Sydney', 
                          LocaleSidKey='en_US', 
                          EmailEncodingKey='UTF-8', 
                          ProfileId='00e90000001NAum', 
                          LanguageLocaleKey='en_US');
        
        insert u;
        Account acc = new Account(Account_Ref__c='1',Name='Test', Reseller_Id__c=1, Virtualisation_Id__c=1);
        insert acc;
        Case cas = new Case (AccountId=acc.Id,OwnerId=u.Id,Type='AU.COM',Status='Open',Brand__c='Netregistry');
        insert cas;
        update u;
        string recordIds = u.Id;

        system.assertEquals(cas.OwnerId, '00G90000001mq6F');
        }
    }
}


I have read other posts saying I need to use Test.startTest(); and Test.stopTest(); but I can't figure out where this fits into a @future class being called via a trigger
Hi,

I'm trying to consume/call a webservice from SAP/APIGEE. I have already the target endpoint to remotes sites settings, etc.

Given the WSDL file from SAP/APIGEE team, I have generated the stub class using "Generate from WSDL"

But when trying to call the service, i am getting this error:
System.CalloutException: Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found 'urn:sap-com:document:sap:soap:functions:mc-style:GetEmployeeResponse'

Here's the WebServiceCallout.invoke lines (if it matters: i can see that the expected response is correctly specified, and yet it looks for something else)
WebServiceCallout.invoke(
              this,
              request_x,
              response_map_x,
              new String[]{endpoint_x,
              '',
              'urn:sap-com:document:sap:soap:functions:mc-style',
              'GetEmployee',
              'urn:sap-com:document:sap:soap:functions:mc-style',
              'GetEmployeeResponse',
              'HLG_sapComDocumentSapSoapFunctionsMcS.GetEmployeeResponse_element'}
            );

I tried to simulate the call using SOAPui, and the result/response is something like this:
<ns1:GetEmployeeResponse xmlns:ns1="urn:sap-com:document:sap:soap:functions:mc-style">
   <Empinfo>
      <EmployeePersonalNumber>10033928</EmployeePersonalNumber>
      <UserName>abhyrtj</UserName>
      <AssignmentType>AB</AssignmentType>
      <AssignmentTypeDescription>test description</AssignmentTypeDescription>
      <CompanyCode>CC</CompanyCode>
      <CmapnyName>Test Company</CmapnyName>
      <Ctps>test</Ctps>
      <CtpsSerie>test</CtpsSerie>
      <CtpsUF>test</CtpsUF>
      <Imss>test</Imss>
      <Nationality>US</Nationality>
      <CountryName>USA</CountryName>
      <AnnualSalary>435345.02</AnnualSalary>
      <AnnualSalaryCurrency>$</AnnualSalaryCurrency>
      <AnnualCurrencyDescription>test description</AnnualCurrencyDescription>
      <WorkContract>AB</WorkContract>
      <WorkContractDescription>test description</WorkContractDescription>
      <EndDate>2017-12-25</EndDate>
      <EmploymentPercentage>98.25</EmploymentPercentage>
      <HoursPerWeek>9.00</HoursPerWeek>
   </Empinfo>
</ns1:GetEmployeeResponse>

THANK YOU SO MUCH IN ADVANCE!
Hello dear community, I have a PDF as a visualforce-component and I want this to be sent automatically as an attachment by a trigger when a new account is added. Any advices ?

Thanks in advance ! :)
Hi,

I want to iterate though the records of Account object inside a trigger of another Object. I tried to do it as follows,

trigger CCTriggerToUpdateAccounts on CC__c (before insert, before update) {
    List<Account> accountList = [SELECT MyField__c FROM Account];
    CC__c[] configs = Trigger.new;
    
    for (Configuration__c c :configs){
        for(Account a: accountList){
            a.Sync_to_AG__c = c.CCID__c;
        }
        update accountList;
    }
}

It works. But The Account iteration goes for several times. I only have 1 Account in my list. 

How can I make it to iterate according to the number of records in the Account object?

Please Help me. Thank you very much in advance.
 
Hello Everyone,
I  am making a callout to external webservices ,I am not getting any error ,
Here is my problem ,When i update values on contact that wont value are not passing to external webservices.
Its passing the random records.
Below is my trigger code and apex Class

trigger Rephistorytracking on contact (after update,before update) {  
    RepTriggerHandlerclass contactHandler = new RepTriggerHandlerclass ();
    Jcoreutil    JcoreHandler= new Jcoreutil();
    if(Trigger.isAfter && Trigger.isUpdate) {
        contactHandler.onAfterUpdate(Trigger.New, Trigger.oldMap);
    }
    
    if(Trigger.IsAfter && Trigger.isUpdate)
    {
        contactHandler.onAftercontactUpdate(Trigger.New);
    }
     if(Trigger.IsUpdate && Trigger.isBefore)
    {
         Jcoreutil.JcoreAdd();
    }
 
}

###################APEX CLASS####################################


public class Jcoreutil {
     @future(callout=true)
     public static void JcoreAdd()
      {
        Set<Id> TerminateCntId= new Set<Id>();
        Set<Id> RepIdsValue= new Set<Id>();
        List<Id> CntListIds= new List<Id>();
        List<contact> TerminateCntList= new List<contact>();
        String LicenseNumber;
         for( contact TerminateCntQuery :[Select Id,Name,CRD__c,FirstName,LastName,Middle_name__c,Gender__c,Address_Type__c,
                                          MailingStreet,MailingCity,MailingState,MailingPostalCode,Email,MobilePhone,
                                          QAM_DSP__r.Name,QAM_DSP__r.CRD__C,QCC_DSP__r.CRD__C,QAM_DSP__r.FirstName,
                                           QAM_DSP__r.LastName,QCC_DSP__r.FirstName,QCC_DSP__r.LastName,Birthdate,Rep_Status__c,
                                           QCC_DSP__c,Term_Date__c,Start_Date__c,LastModifiedDate,HomePhone,Phone,OtherPhone
                                            from Contact where (Rep_Status__c='Terminated'OR Rep_Status__c='Converted') Limit 1])
         {
              system.debug('TerminateQuery@@@@'+TerminateCntQuery);
               if(TerminateCntQuery.Rep_Status__c=='Converted')
               {         
             TerminateCntList.add(TerminateCntQuery);
             TerminateCntId.add(TerminateCntQuery.id);
             List<License__c> lstLicensesValues=new List<License__c>();
             License__c LicensesValues=[Select Id,License__c from License__c where contact__c  IN:TerminateCntId Limit 1] ;
             lstLicensesValues=[Select Id,License__c from License__c where contact__c  IN:TerminateCntId];
             integer LicensesValue;
             LicensesValue=lstLicensesValues.size();

Please help me

I Tried to pass the list of ids,but its give error while calling method in trigger.

Thanks.

Regards,
Jyo
 

hello community, when I was executing with a debug to check on my class this occured:

User-added image

that's the code for the class:

public class HelperContactTrigger {
    //static method
    public static List<Account> sendEmail(List<Account> accounts) {

        //query on template object
        EmailTemplate et=[Select id from EmailTemplate where name= 'Sales: New Customer Email' limit 1];

        system.debug(et);   //debug to check the template

        //list of emails
        List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();

        //loop
        for(Account con : accounts){

            //check for Account
            if(con.PersonEmail == null && con.PersonEmail != null){

                //initiallize messaging method
                Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();

                //set object Id
                singleMail.setTargetObjectId(con.Id);

                //set template Id
                singleMail.setTemplateId(et.Id);

                //flag to false to stop inserting activity history
                singleMail.setSaveAsActivity(false);

                //add mail
                emails.add(singleMail);
            }
        }

        //send mail
        Messaging.sendEmail(emails);
        return accounts;
    }
}

What do I do? I checked the code and everything a million times.
I was having difficulties running a test class for this programm (System.QueryException: List has no rows for assignment to SObject)
so I have to check if the query statement really does what it's supposed to, it has to work as a mailtrigger when a new account is added but the query is having issues so I have to know what the real problem is.

This is the test class:

@isTest
private class HelperContactTriggerTestneuer {
public static testMethod void myTestMethod() {

        Account acc = new Account(Name = 'Test Test');
        insert acc;

        List<Account> sendMail = [select id from account where (Name='Test Test') and id=:acc.id];
   EmailTemplate testTemplate=new EmailTemplate(Name='Neuer Kunde',DeveloperName='Neuer_Kunde',FolderId=Userinfo.getUserId());
   insert testTemplate;

        HelperContactTrigger.sendEmail(sendMail);
        System.assert(acc !=null);
        
        }
        }


thanks in advance :)

Hi,
 In my visualforce page i am using getContentAsPDF() for generating feeditem.
After saving the data i am generating feeditem. At this point Feeditem is not having recently saved data.
i suspect getContentAsPDF() not getting the recent data.
Can anybody help me on this?

 
I have made changes and it is still not compiling or saving to SFDC.....  here is my modified code after debugging.  Can anyone see what I am missing.

First thing that should happen is when a new buyer record is saved or updated (identified by the Active_Buyers__c) field is search through system for records that have (Active_Seller__c) field checked.

Then it should query the account records and pull the ID, name, List Price, Price Range, Owner Email, and Last Modified Email. from the account object where the List Price <= to the Price range  and store the results temporarily.

After matches are returned there should be an email notification sent to the LastModifiedByID.email of the record that has the Active Seller field checked. with the 

Subject being New Buyer Found, 
Body should contain the account name (hyperlink) owner name and owner email of the account with the Active buyers field checked




trigger BuyerSellerMatchTrigger on Account (after insert,after update){
// Capture all records that have Active_Buyers__c field equals true
      List <Account> BuyerList = new List<Account>();
      Set<String> nameSet= new Set<String>();
      Set<String> emailSet;
      Boolean Active_Buyers = true;
         for(Account a:trigger.new){      
           if(Active_Buyers__c) {
            buyerList.add(a.);
            nameSet.add(a.name);
         }
        }
//check to determine size and the query fields of accounts for the buyer list
        if(buyerList.size()>0 && nameSet.size()>0){
       List<Account>listOfAccounts=[ select id, name, owner.email, Maximun_Price_Range__c, Price_range__c 
           from Account where (name in: nameSet) and Active_Seller__c = True and Listed_Price__c <= Price_Range__c];
//Map the result set of active buyers to active sellers
         Map<Id, Set<String>>mapOfAccounts=new Map<Id, Set<String>>();
         for(Account a:listOfAccounts){
            for(account trgrAccountbuyerList){
               if(trgrAccount.Active_Seller__c = True){
                 if(mapOfAccounts.containsKey(trgrAccount.id)
                 &&!mapOfAccounts.get(trgrAccount.id).contains(a.owner.email))
            }
    }
  emailSet=mapOfAccounts.remove(trgrAccount.id);
                            emailSet.add(a.owner.email);
                            mapOfaccounts.put(trgrAccount.id,emailSet);
                        }
                       else {
                            emailSet=new Set<String>();
                            emailSet.add(a.owner.email);
                            mapOfaccounts.put(trgrAccount.LastModifiedByid,emailSet);
                        }
                    }
                }
            }
// Email notification trigger
            for(Id idey:mapOfaccounts.keySet()){                              
                String emailMessage='Buyer Email account-https://na7.salesforce.com/'+ idey;
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses=new List<String>();
                toAddresses.addAll(mapOfaccounts.get(idey));
                mail.setToAddresses(toAddresses);
                mail.setReplyTo('noreply@salesforce.com'); 
                mail.setSenderDisplayName('Buyer Email'); 
                mail.setSubject('Subject');
                mail.setPlainTextBody(emailMessage);
                mail.setHtmlBody(emailMessage);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});                               
            }       
        }   
}
}
Hi Everyone,

i have a vf page which contains a button, with a record.
i want to enable button based on record owner.contion here i want to enable it only if record owner is other than created user of record.
EX: lets say User A is create record.if user is opened that opened the page contains this record.this time button needs to disabled.
If user B opened this page contains user A created record.this time it needs to be enabled.

can some one help tel me the condtion please.

Regards
Lakshman
 
I wrote a trigger to create a new case when a closed case receives a mail. It works absolutely fine on sandbox but not working on production.

trigger EmailMessageAfterUpdate on EmailMessage (after insert) {
   
// limit 1001 used, else it was giving error "System.LimitException: Too many query rows: 50001".

   List<case> caseList = [Select id, Status from Case where Status = 'Closed' limit 1001];
            for (EmailMessage newEmail : Trigger.new) 
            {     for(case cc : caseList){
                       if(cc.Status == 'Closed' && cc.id == newEmail.ParentId){ 
                            Case newCase = new Case();
                            newCase.Subject = newEmail.Subject;
                            newCase.Parent_Case__c=newEmail.ParentId;
                            newCase.Category__c = newEmail.Parent.Category__c;
                            newCase.BusinessHours = newEmail.Parent.BusinessHours;
                            newCase.Status = 'Re-Opened';
                            newCase.Sub_Status__c = newEmail.Parent.Sub_Status__c;
                            insert newCase;
                         }
                   }
             }
}
I have written a trigger that when an account record is inserted or updated and the Active_buyers__c field equals True, it will search the system for all accounts that have the field Active_seller__c = true and the the List price from the account that has the active seller eqquals true is less than or equal to the price range of the account with the active buyers equal true.

If a match is found it would then send an email notification to the lastmodifiedBy user of the active seller equals true record to notify them of a potential buyer.

I am getting errors with this code and it will not compile..... 

Can someone look at my code and tell me where I went wrong?


trigger BuyerSellerMatchTrigger on Account (after insert, after update) {
        List<Account> buyerList=new List<Account>();
        Set<String> nameSet=new Set<String>();
        Set<String> citySet=new Set<String>();
        Set<String> emailSet;
        for(Account a:trigger.new){
            if(a.Active_buyers__c='True'){
                buyerList.add(a);
                nameSet.add(a.name);
           
            }
        }
        if(buyerList.size()>0 && nameSet.size()>0){
            List<Account> listOfAccounts=[select id,name,BillingCity,owner.email,Price_range__c from account where (name in :nameSet) and Active_seller__c='True'];
            Map<Id,Set<String>> mapOfAccounts=new Map<Id,Set<String>>();
            for(Account a:listOfAccounts){
                for(account trgrAccount:buyerList){
                    if(trgrAccount.Active_Seller__c='True' && trgraccount.list_price__c=a.Price_range__c){
                        if(mapOfAccounts.containsKey(trgrAccount.id) && !mapOfAccounts.get(trgrAccount.id).contains(a.owner.email)){
                            emailSet=mapOfAccounts.remove(trgrAccount.id);
                            emailSet.add(a.owner.email);
                            mapOfaccounts.put(trgrAccount.id,emailSet);
                        }else {
                            emailSet=new Set<String>();
                            emailSet.add(a.owner.email);
                            mapOfaccounts.put(trgrAccount.LastModifiedByid,emailSet);
                        }
                    }
                }
            }
            for(Id idey:mapOfaccounts.keySet()){                              
                String emailMessage='Buyer Email account-https://na7.salesforce.com/'+ idey;
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses=new List<String>();
                toAddresses.addAll(mapOfaccounts.get(idey));
                mail.setToAddresses(toAddresses);
                mail.setReplyTo('noreply@salesforce.com'); 
                mail.setSenderDisplayName('Buyer Email'); 
                mail.setSubject('Subject');
                mail.setPlainTextBody(emailMessage);
                mail.setHtmlBody(emailMessage);
                Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});                               
            }       
        }   
    }