• unidha
  • NEWBIE
  • 85 Points
  • Member since 2012

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 13
    Questions
  • 32
    Replies
I created trigger to populate default value.I also create validation rules to check that the field should not be empty only on update record.It should not fire if user create new record.The issue is, test class fail due to process builder throw validation rule exception.
 
//trigger
trigger Opportunity_Trigger on Opportunity (before insert) {
   if (Trigger.isBefore)
   {
     if(Trigger.isInsert)
      {
            OpportunityTriggerHandler.populateDefaultData (Trigger.new);
      }
     }

}
 
//in trigger framework

 public static  void populateDefaultData (List<Opportunity> newOppList)
        {
            Set<Id> setUser = new Set<Id>();
           for (Opportunity opp : newOppList) 
          {  setUser.add(opp.OwnerId);

           }

          Map<Id, User> mapUsers = new Map<Id, User>([SELECT Id, UserDivision__c FROM User WHERE Id IN :setUser ]);

          for (Opportunity opp : newOppList) 
          {

            User owner =mapUsers.get(opp.OwnerId);


            if(owner.UserDivision=='APAC' && String.IsBlank(opp.OwnerDivision__c))
            {
                    opp.OwnerDivision__c = owner.UserDivision;
             }
        }
    }

Validation Rules
IF(ISNEW(), 
False, 
ISBLANK( TEXT(OwnerDivision__c) )
)

Process builder criteria
(isnew()=TRUE
||  
ischanged([Opportunity].StageName)=TRUE)
&&
[Opportunity].IsClosed=FALSE
Process builder action
update StageStatus with Opportunity.StageName

Test class
@isTest(SeeAllData=false)
private class Opportunity_TestClass {

 //contains insertion for Account 
    @testSetup static void setupData()
    {               
        //create account  
        Account account1=new Account(Name='Account 1',Country__c='Denmark');

        insert listAccount;

    }

 static testMethod void  testPopulateData()
    {
        //insert user
        Profile p = [SELECT Id,Name FROM Profile WHERE Name='Sales APAC']; 
        UserRole userRole=[SELECT Id FROM UserRole where Name ='Manager'];
        List<User> lstUser = new List<User>();

        String orgId = UserInfo.getOrganizationId();
        String dateString = String.valueof(Datetime.now()).replace(' ','').replace(':','').replace('-','');
        Integer randomInt = Integer.valueOf(math.rint(math.random()*1000000));

        String uniqueName =  orgId + dateString + randomInt;

        User userOne = new User(Alias = 'userOne', Email='userOne@abc.com', 
                                   EmailEncodingKey='UTF-8', LastName='userInt', LanguageLocaleKey='en_US', 
                                   LocaleSidKey='en_US', ProfileId = p.Id, 
                                   TimeZoneSidKey='America/Los_Angeles', UserName=uniqueName + '@test' + orgId + '.org',Employee_ID__c ='123',
                                   UserRoleId=userRole.id,UserDivision__c ='APAC', 
                                );

        insert userOne ;



        List<User> lstInsertedUser = [select Id from User where LastName in ('userOne')];

        system.assertEquals(1,lstInsertedUser.size());

        Test.startTest();

        List<Account> lstAccount =[Select Name,Id from Account where Name ='Account 1'];

        System.runAs(lstInsertedUser[0]) 
        {
            System.debug('Current User: ' + UserInfo.getUserName());
            Opportunity testOpp = new Opportunity(Name='Oppo 1', StageName='Create',
                                                  CloseDate=Date.TODAY()+20, amount=10000,AccountId=lstAccount[0].Id);

            insert testOpp;    

            system.assertEquals(1,[Select count() from Opportunity where Name='Oppo 1']);

        }

        Test.stopTest();
    }

}

I am stuck because logically it should not fire the exception.The data is inserted through trigger.
 
I remembered last time I can format the code, but I am not able to see any icon to format code either in IE or Chrome.What happen?How to post code here?


trigger Opportunity_Trigger on Opportunity (before insert) { if (Trigger.isBefore) { if(Trigger.isInsert) { OpportunityTriggerHandler.populateDefaultData (Trigger.new); } } }
First we create Lightning App which is  helloAttributes.app.After that we need to create helloAttributes.cmp , it prompt error saying DUPLICATE_VALUE while I haven't create any component yet.With this error, I am not sure how to proceed with the rest.
  • September 15, 2015
  • Like
  • 0
I found this by accident while trying to implement user requirement.I code this in Apex Execute Anonymous:
 
List<Decimal> lstDecimal =new List<Decimal>{0.0,0.00};
Set<Decimal> setDecimal =new Set<Decimal>(lstDecimal);
system.debug('@NUR ..'+setDecimal+ ', '+setDecimal.size());

But the result come out as below:
19:03:56:076 USER_DEBUG [3]|DEBUG|@NUR ..{0.0}, 2
Anyone knows why it only print {0.0}  instead of {0.0,0.00} ? The size clearly state it has two elements.Is it Salesforce bug?

Note: The question is enhanced from this forum (http://salesforce.stackexchange.com/questions/65227/set-contains-decimal-to-check-if-the-elements-all-zero/65232#65232) ,but I am asking here in case anyone from Salesforce can answer this.

Thank you .

 
  • February 05, 2015
  • Like
  • 0

Hi,

 

I did some code that doing callout.It works and I planned to put in trigger based on the requirement.But when I put it inside trigger it required me to put @future in the callout method.So I did that, but my method no longer works.I suspect it due @future because when I run at Apex Execute it not able to return value but when I remove @future it return it successfully.I am not sure why this happen? Any idea?

 

Here the snippet of my code 

 

for(User us : mapUserToProcess.values()){

   system.debug('@email== '+us.email);//this one is return the value
   getUserByEmail(us.email);
   String strXML = returnStr;

}


@future(callout=true)
       static void getUserByEmail(string email)

    {
        String baseUrl = url+'/2.0/admin/users/'+email;
        GetAccessToken();
        
        system.debug(' baseUrl for getUserByEmail  '+ baseUrl );

        HTTPRequest request = new HTTPRequest();              
        request.setEndpoint(baseUrl);
        String authorizationHeader = 'WRAP access_token=' + accessToken;
        request.setHeader('Authorization', authorizationHeader);
        request.setHeader('Content-Type', 'application/json');
        request.setMethod('GET');
        request.setTimeout(120000);

        HTTP http = new HTTP();
        HTTPResponse response =  http.send(request);
        
        if(response.getStatusCode()!=200){
           returnStr=response.getStatusCode() +' : '+  response.getStatus();
           errorCode=response.getStatusCode();
           errorMessage=returnStr;
         }
        
        else {
        
           returnStr=response.getBody();
        
        }
        
        system.debug(' returnStr  '+ returnStr);
    }

 If I removed @future, it will go into the getUserByEmail and retrieve the returnStr value.But if I put @future, it not even print out the system.debug and not even return value for returnStr.

 

Thanks.

 

 

 

 

  • November 26, 2013
  • Like
  • 0

Hi,

 

I am trying to do tutorial on XMLReader, all went okay until I modified xml file to have element child  such as below.

 

<User xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
 <CreatedDate>11/7/2013 5:52:12 PM</CreatedDate>
<Id>31209297</Id>
  <DisplayName>Unidha</DisplayName>
<Email>unidha@yahoo.com</Email>
<UserGroups>
 <UserGroup><Id>301</Id><Name>Administrators</Name></UserGroup> <UserGroup><Id>302</Id><Name>Sales</Name></UserGroup>
</UserGroups>
</User>

 

 

I want to Group Id to List of String of Employee object.Here is my code, I am not able to read UserGroups element such as UserGroup Id and User Group Name.Any Idea?

 

 public class MyXmlStreamReader {

public List<Employee> listRecords = new List<Employee>();

   //object that hold information on transaction,user etc.
     class Employee{
        
       private List<String> GroupId{get;set;} //one user might have multiple group being assigned
         private Boolean autoProvision{get;set;}
        private Id userId{get;set;}
        private String email{get;set;}
        private String firstName{get;set;}
        private String lastName{get;set;}
        private String displayName{get;set;}
      
   
    }
    
    public void test() {
     String str = '<User xmlns:i="http://www.w3.org/2001/XMLSchema-instance">'
                  +'<CreatedDate>11/7/2013 5:52:12 PM</CreatedDate>'
                  +'<Id>31209297</Id>'
                   +'<DisplayName>Unidha</DisplayName>'
                   +'<Email>unidha@yahoo.com</Email>'
                   +'<UserGroups>'
                   +'<UserGroup><Id>301</Id><Name>Administrators</Name></UserGroup>'
                   +'<UserGroup><Id>302</Id><Name>Sales</Name></UserGroup>'
                   +'</UserGroups></User>';
                   
     XmlStreamReader xsr = new XmlStreamReader(str);
    readResponse(xsr);
  
     }

   public void readResponse(XmlStreamReader reader) {
     Employee empRecord; 
    // List of emp to store the value
    List < Employee > empList= new list < Employee > (); 

    while (reader.hasNext()) { 
          if (reader.getEventType() == XmlTag.START_ELEMENT) { 
             if ('User' == reader.getLocalName()) {
                  empRecord= new Employee ();
            } else if ('CreatedDate' == reader.getLocalName()) {
                 system.debug('@UNID--- '+getValueFromTag(reader)); 
            }
            
            else if ('Id' == reader.getLocalName()) {
                 system.debug('@UNID Id--- '+getValueFromTag(reader)); 
            }
             else if ('Display Name' == reader.getLocalName()) {
                empRecord.displayName= getValueFromTag(reader);
                system.debug('@UNID displayName =='+ empRecord.displayName);
            }
             else if ('Email' == reader.getLocalName()) {
                // If you find any other opening tag, extract the string value
                empRecord.email= getValueFromTag(reader);
                system.debug('@UNID Email=='+ empRecord.email);
            }
           else if('UserGroups' == reader.getLocalName()) {
                empRecord.GroupId=new List<String>();
                 system.debug('@UNID =='+ empRecord.email);
               
                      
            }
            else if('UserGroup' == reader.getLocalName()  ) {
            //HOW TO READ USER GROUP ELEMENT add the Id into GroupId
                   if(reader.getEventType() == XmlTag.CHARACTERS){
                    system.debug('@UNID =='+ empRecord.email);
                   
                     }
                empRecord.GroupId.add(getValueFromTag(reader));
                 }
           
        }
        
       /* else if (reader.getEventType() == XmlTag.END_ELEMENT){
        
              if('UserGroup' == reader.getLocalName()){
               system.debug('@UNIDEnd UserGroup=='+ getValueFromTag(reader));
              }
              
              else if('UserGroups' == reader.getLocalName()){
              system.debug('@UNIDEnd UserGroups=='+ getValueFromTag(reader));
              }
        }
        */
        
           
        
        reader.next();
    }
}
    
    
   // This is an extra function to read data between opening and closing tag. 
// It will return the string of value from between tags
public string getValueFromTag(XMLStreamReader reader) {
    String DataValue;

    while (reader.hasNext()) {
        if (reader.getEventType() == XmlTag.END_ELEMENT) {
            break;
        } else if (reader.getEventType() == XmlTag.CHARACTERS) {
            DataValue = reader.getText();
        }
        reader.next();
    }

    return DataValue;
}   
      


}

 

Thanks a lot.

 

  • November 18, 2013
  • Like
  • 0

Hi,

 

I am not sure this is a right place or not, but let me explain about this.

 

I have Apex page and apex component . Click here to see my  page structure.

 

At page level I have tab that constructed dynamically  and component like simplified code below.

 

Tab code at page level

  <apex:repeat value="{!segmentSelected}" var="seg">
            <li class="{!IF(ISNULL($CurrentPage.parameters.segmentTab) && rowNum == 1,'ui-tabs-active',IF($CurrentPage.parameters.segmentTab == seg,'ui-tabs-active',''))}"  style="padding: 0px !important;">
                      <span style="float:left;font-size:14px;align:center;margin-top:5px;margin-left:0px">
                    <apex:commandLink  value="{!seg}" rerender="segment,report">
                        <apex:param name="segmentTab1" value="{!seg}" />
                        <apex:param name="segmentTab2" value="{!seg}" />
                    </apex:commandLink>
                </span>
            </li>
			<apex:variable var="rowNum" value="{!rowNum + 1}"/>
 </apex:repeat>

 

Component code

 <apex:component controller="MyReport" access="global" allowDML="true"> 
  <apex:repeat value="{!mylist}" var="c">
    <td class="comments">
<apex:inputTextArea style="border: none;width:420px;resize:none;" styleclass="txtaresexpone" value="{!c.Comments__c}"> <apex:actionSupport action="{!saveMyList}" status="inProgress" event="onchange" rerender="dummy"> </apex:actionsupport> </apex:inputTextarea></td> </apex:repeat> </apex:component>

 

Each tab represent different data with the same Object type.Component will display the detail of the Object based on the tab.Example the user click Tab 1 contain value Emp Name, the component will render the Emp Detail that belong to Tab 1.

 

The issue is when user update multiple field of  Emp Detail in component and directly click on different tab.The system is using actionSupport to save the detail, and if the user directly click on different tab after updating field from different tab, the system will save some of the detail with the recent clicked  tab while the data should belong to previous tab.

 

How I can control this? Is there any function that will ensure all the actionSupport completed before the apex:commandlink get executed?

 

Note: I already put actionStatus for every actionSupport but still is not helping.

 

Thanks,

unidha

  • October 02, 2013
  • Like
  • 0

Hi,

 

I am not sure my Subject is correctly write or not.But I faced issue on something like this,

 

Example I have one object named Employee with contains attribute such  InternalID ,ExternalID, name , age

 

I need to retrieve the data where InternalId = ExternalID something like below

 

select Name, Age__c  from Employee__c where InternalID__c = ExternalID__c 

 

 

I knew in Oracle we can do something like this, but I m not sure in SFDC can we do that?Usually if there requirement to do that, what is the best way to do it?

Hi,

 

I did some code to  insert Document thru apex and successfully work. For Document Name and Developer Name, I generate it dynamically  by concatenate it with some variables and object name. Something like below

docName= 'XX_'+autoNumber+'_'+accountName+'_'+ accountCountry;
		    	 
document.Name =docName;
document.DeveloperName=docName;
document.isPublic=true;
document.FolderId=folderId;
		    	
upsert document;

 

 

The issue is, I manually delete the Document  and run my apex code to insert  back the Document but I face this error:

 

First exception on row 0; first error: DUPLICATE_DEVELOPER_NAME, This Document Unique Name already exists or has been previously used.  Please choose a different name

 


Well,I do not understand why it prompt me this  error as I already deleted the Document.I already check the Document and it could not be found.

 

Here the method how I check the Document, unfortunately it return nothing.I also remove isDeleted and still it return nothing.If it return nothing, the duplicate issue should not happen at the first place as the Document is not there.Or is it different case for Document.

 

SELECT Name, DeveloperName, Type, IsDeleted FROM Document where DeveloperName like 'XX_100%' and isDeleted=true

 Thanks,

unidha

Hello all,

 

I want to ask if it possible or not to share/pass a list variable between two controller.Scenario is something like this:

 

I have one page named Page1 which is using StandardController Account and extension  named Extension1.

 

In this Extension1, I defined one list variable that contain all element which I used to contruct tab in Page1.

 

Then I created one component named Component1 with controller named Controller1.In this component, I put all the content that I want to display for every tab that constructed in Page1, to do this I just pass one list element as string .

 

So I have Page1 and inside it contain Component1.Now, where the issue come out. In the Controller1, I need to know all the element in the list variable that I defined in Extension1 in order to do some processing/ mathematical calculation. In order word, I need to retrieve the list from Extension1 in Controller1.

 

Is it possible to do this? Any Idea?

 

 

Hi ,

 

I know this is quite naive question but when I went through all the posted solution still I am not understand  the concept very well.

Here is my snippet of my code:

 

System.debug('check variable =' + qtr + segment + accId ); 

List<MyAccount__c>  lstReport=[Select id , Segment__c,(Select id,Name__c from  Account_Competitor__r)from MyAccount__c  where Fiscal_Quarter__c=:qtr    and Segment__c in :segment and MyAccount__c=:accId];

if(lstReport==null){
            System.debug('if null should return here'); 
          	lstReport=new List<MyAccount__c> ();
           
}

 

 

 

I already run the query in the Force.com console and yes it return no data with the printed variable in System.debug('check variable =' + qtr + segment + accId );  .

 

So I expect it should be null, as it also throw me Attempt to de-reference a null.

 

But it didn't enter the condition if(lstReport==null). So what I should do to check it is  return null value? 

 

Thanks in advance

unidha

Hi,

 

I know the Data loader have the features to accept data contain coma with condition it must enclosed with double quote.I want to know how to code it using apex class.

 

For example CSV File  contain data  "ACME", "Acme,Owner ,Friend", "000"

 

I want the data to be read as below.It should retun 3 columns.

ACME

Acme,Owner,Friend

000

 

Currently the code that I have is working like this.It return 5 columns.

"ACME"

"Acme

Owner

Friend"

"000"

 

I tried this http://wiki.developerforce.com/page/Code_Samples#Parse_a_CSV_with_APEX but didn't get the result that I want.

Any idea?

 

Thanks,

unidha

  • February 22, 2013
  • Like
  • 0

Hi,

 

I try to get the referer, but it returning me null when I run it.          

 

Here the code that I put in extension

 

String mktg_ref= (String)ApexPages.currentPage().getHeaders().get('Referer');

 

 

This is example of page that I run https://ap1.salesforce.com/apex/Marketing_coupon?id=a5QV00000004E17

 

Please advise.

 

Thanks,

unid

  • January 16, 2013
  • Like
  • 0
I remembered last time I can format the code, but I am not able to see any icon to format code either in IE or Chrome.What happen?How to post code here?


trigger Opportunity_Trigger on Opportunity (before insert) { if (Trigger.isBefore) { if(Trigger.isInsert) { OpportunityTriggerHandler.populateDefaultData (Trigger.new); } } }
I found this by accident while trying to implement user requirement.I code this in Apex Execute Anonymous:
 
List<Decimal> lstDecimal =new List<Decimal>{0.0,0.00};
Set<Decimal> setDecimal =new Set<Decimal>(lstDecimal);
system.debug('@NUR ..'+setDecimal+ ', '+setDecimal.size());

But the result come out as below:
19:03:56:076 USER_DEBUG [3]|DEBUG|@NUR ..{0.0}, 2
Anyone knows why it only print {0.0}  instead of {0.0,0.00} ? The size clearly state it has two elements.Is it Salesforce bug?

Note: The question is enhanced from this forum (http://salesforce.stackexchange.com/questions/65227/set-contains-decimal-to-check-if-the-elements-all-zero/65232#65232) ,but I am asking here in case anyone from Salesforce can answer this.

Thank you .

 
  • February 05, 2015
  • Like
  • 0
I wrote a test class for the following class ...but while saving am getting this error Whats wrong in my code...thanks



Error Error: Compile Error: Invalid constructor syntax, name=value pairs can only be used for SObjects at line 8 column 32


my test class


@isTest
private class TestAccountcontactroleClass{
    @isTest
    private static void testClass()
    {
    //Standard controller of Accountcontactrole
    //Create a new instance of Accountcontactrole
    AccountContactRole  accs = new AccountContactRole(Account.Name = 'TestAccountName',Role='Newrole',IsPrimary='True' );

    //Insert the object virtually
    insert accs;

    //Create a new instance of standard controller
    ApexPages.StandardController sc = new ApexPages.standardController(accs);

    AccountContactRoles controller = new AccountContactRoles(sc);
    }
}



My class


public with sharing class AccountContactRoles {
    private final Contact acr;
   
    public AccountContactRoles(ApexPages.StandardController controller){
        this.acr = (Contact)controller.getRecord();
    }
   
    public List<AccountContactRole> acrs {
        get {
            if (acrs == null) {
                acrs = [Select Id, Account.Name,
                     Role, IsPrimary
                    From AccountContactRole
                    Where ContactId=:acr.Id
                    ];               
            }
            return acrs;
        }
        private set;
    }
}




I need help ...thanks in advance
Hey everyone,

Let me briefly explain the trigger I wrote (my frist trigger actually). On the opportunity, we have a look-up field to other opportunities called 'Renewed Opportunity'. The idea is that when you create an opp that is a renewal, you use that field to reference the previous opportunity that is being renewed.

The trigger looks at the stage of the new renewal opp and updates a field on the referenced 'Renewed Opporunity' called 'Renewal Status'. The goal is to be able to see if an opp ended up renewing or not.

The issue here is that many of our older opportunities don't meet the validation rules we currently have in place. So if you populate that look-up field with an opp with missing data, you'll get an error message preventing you from updating the new, renewal opp you're creating.

Obviously, one solution would be to go back and update all our older opps, but that's practically impossible. So here is my question:

1) Is there something I can write in either the trigger or the validation rules to set up a bypass? For the validation rules, I tried writing in 'NOT(ISCHANGED(Renewal_Status__c))', but it seems that as long as a record is referenced, the validation rules will be required. The trigger doesn't even have to update the record.

2) If option 1 is not possible, is there a way to write an error message in the trigger that at least explains to the user in a clear manner that they have to update the referenced opp? I'd also like to list in the error the validation rules that must be met, but that would be a bonus.

In case you want to take a look at my trigger, here it is:


trigger RenewalProcess on Opportunity (after insert, after update) {
   
   Set<String> allOpps = new Set<String>();
    for(Opportunity renewalOpp : Trigger.new) {
        if (renewalOpp.Renewed_Opportunity__c != null) {
            allOpps.add(renewalOpp.Renewed_Opportunity__c);
         }
    }

    List<Opportunity> potentialOpps = [SELECT Id FROM Opportunity WHERE Id IN :allOpps];

    Map<String,Opportunity> opportunityMap = new Map<String,Opportunity>();
        for (Opportunity o : potentialOpps) {
            opportunityMap.put(o.id,o);
        }
     
     List<Opportunity> oppsToUpdate = new List<Opportunity>();
       
        for (Opportunity renewalOpp : Trigger.new) {
            if (renewalOpp.Renewed_Opportunity__c != null && renewalOpp.StageName.equals('Closed Won')) {
                Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
                renewedOpp.Renewal_Status__c = 'Renewed';
                oppsToUpdate.add(renewedOpp);
            }
            else if(renewalOpp.Renewed_Opportunity__c != null && !renewalOpp.IsClosed) {
                Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
                renewedOpp.Renewal_Status__c = 'In Negotiations';
                oppsToUpdate.add(renewedOpp);
            }
            else if(renewalOpp.Renewed_Opportunity__c != null && (renewalOpp.StageName.equals('Closed Lost') || renewalOpp.StageName.equals('Closed Stalled'))) {
                Opportunity renewedOpp = opportunityMap.get(renewalOpp.Renewed_Opportunity__c);
                renewedOpp.Renewal_Status__c = 'Did Not Renew';
                oppsToUpdate.add(renewedOpp);
            }
           
           
        }
   
    update oppsToUpdate;
   
}



Let me know if you need anymore info from me!
-Greg

Hi,

 

I did some code that doing callout.It works and I planned to put in trigger based on the requirement.But when I put it inside trigger it required me to put @future in the callout method.So I did that, but my method no longer works.I suspect it due @future because when I run at Apex Execute it not able to return value but when I remove @future it return it successfully.I am not sure why this happen? Any idea?

 

Here the snippet of my code 

 

for(User us : mapUserToProcess.values()){

   system.debug('@email== '+us.email);//this one is return the value
   getUserByEmail(us.email);
   String strXML = returnStr;

}


@future(callout=true)
       static void getUserByEmail(string email)

    {
        String baseUrl = url+'/2.0/admin/users/'+email;
        GetAccessToken();
        
        system.debug(' baseUrl for getUserByEmail  '+ baseUrl );

        HTTPRequest request = new HTTPRequest();              
        request.setEndpoint(baseUrl);
        String authorizationHeader = 'WRAP access_token=' + accessToken;
        request.setHeader('Authorization', authorizationHeader);
        request.setHeader('Content-Type', 'application/json');
        request.setMethod('GET');
        request.setTimeout(120000);

        HTTP http = new HTTP();
        HTTPResponse response =  http.send(request);
        
        if(response.getStatusCode()!=200){
           returnStr=response.getStatusCode() +' : '+  response.getStatus();
           errorCode=response.getStatusCode();
           errorMessage=returnStr;
         }
        
        else {
        
           returnStr=response.getBody();
        
        }
        
        system.debug(' returnStr  '+ returnStr);
    }

 If I removed @future, it will go into the getUserByEmail and retrieve the returnStr value.But if I put @future, it not even print out the system.debug and not even return value for returnStr.

 

Thanks.

 

 

 

 

  • November 26, 2013
  • Like
  • 0

Hi All,

 

I am having really tough time dealing with Salesforce Test classes.

 

My first problem is when I write a test class, then the class I am testing does not show up in Overall Code Coverage.

 

Then when I click on test the class does show up in Class Code Coverage and show me the coverage % but when I click on it it opens without the colors telling me which line is covered and which is not.

 

 

Please let me know how to resolve this.

 

Thanks.

Anyone know how to put a content Previewer on Visualforce page?

Hi,

 I am new in Salesforce...I want to design a pop up window. The window will appear after save button is hit which will show the values those an user has entered as input. After the pop up comes out then the user will click the ok in pop up and the page will be redirected to the object view page.

 

Now how can I implement it throgh java script or any other possible way.

Can u pls provide some sample coding for it.

 

Thanks in advance,

  • September 28, 2011
  • Like
  • 0

I have a confirmation dialog with Ok and Cancel button. When user clicks OK I would call server action to proceed and on cancel no server call is necessary.

 

I want to use the apex:commandButton for both to make sure that they use the same css style. Even if I do not have the action parameter the command submits a call to the server. 

 

 

 

  • August 29, 2011
  • Like
  • 0

We are currently trying to develop an application on VF where we need to embed charts in PDF. Wanted to see if any one had tried it before or forsee any issues with it.
I had found the following article regarding charts and VisualForce

http://wiki.developerforce.com/index.php/Google_Visualizations

Girish

Principal

CM-Focus LLC

 

 

Ok, so the driving force this this piece of code was to reassign leads for Users that are made inactive to a Queue to reassigned to other sales reps. Seems like a relatively common situation, right?

 

Seemed like a pretty simple trigger to right as well, even for a beginner like myself.  Unfortunately I appear to be wrong in that assumption.

 

From my reading it seems that we cannot update other records (Leads, Contacts, Accouts, etc.) when a User's profile is updated. Is that really the case or am I missing something terribly obvious here?

 

 

trigger ReassignSalesLeadstoSupervisorforInactive on User (after update) { //Get Id for Sales Supervisors Queue Group sup = [SELECT Id FROM Group WHERE Name='Sales Supervisors' AND Type='Queue']; Set<Id> inactive = new Set<Id>(); List<Lead> reassign = new List<Lead>(); //Determine if user is a Sales User that has just been made Inactive for(user u : trigger.new){ if(u.Department == 'Sales' && Trigger.oldMap.get(u.id).IsActive == True && u.IsActive == False){ inactive.add(u.id); } } System.debug('****Users****'+inactive); //Find the inactive user's leads and reassign them to the Sales Supervisors Queue for(Lead l : [SELECT Id,OwnerId FROM Lead WHERE OwnerId IN :inactive]){ l.OwnerId = sup.id; reassign.add(l); } System.debug('****Leads****'+reassign); update reassign; }

 

 

 

I tried many things on how to customize this but find nothing effective. I want to put a text message on the Page Layout I created, how can I do that? Anyone who know how to configure this? Please help me again.

 

Hi, 

 

I have a radio button table in VF and I want to flip it to where it is lined up vertical. 

 

Here is the code: 

 

 

<apex:dataTable value="{!category.questions}" var="question" id="questionList" width="1000px" rowClasses="odd,even" cellPadding="3px;" border="0"> <apex:column > <B><apex:outputText value="{!question.Assessment_Question_Template__r.Question_Text__c}" /></B> </apex:column> <apex:column colspan="4"> <apex:selectRadio style="width: 100%" border="0" id="radioTable" value="{!question.Value__c}" disabled="true"> <apex:selectOption itemValue="1" itemLabel="1" /> <apex:selectOption itemValue="2" itemLabel="2" /> <apex:selectOption itemValue="3" itemLabel="3" /> <apex:selectOption itemValue="4" itemLabel="4" /> <apex:selectOption itemValue="5" itemLabel="5" /> <apex:selectOption itemValue="6" itemLabel="6" /> <apex:selectOption itemValue="7" itemLabel="7" /> </apex:selectRadio> <script> var radioTable = document.getElementById("{!$Component.radioTable}"); var el = radioTable.getElementsByTagName("TD"); el[0].style.width = "175px"; el[0].align = "center"; el[1].style.width = "95px"; el[2].style.width = "95px"; el[3].style.width = "95px"; el[4].style.width = "95px"; el[5].style.width = "95px"; </script> </apex:column>

 

 

Ideallly, it would be <column> radio button <column> < text>  

                             <column> radio button < column> <blank>

                             <column> radio button <column> < text>

                             etc. 

 

 

Might be a silly question, but from what I've read about radio buttons is they can't be stacked like that.. is that true? 

 

Thanks in advance. 

T

 

 

 

I have been tasked with finding some solutions for a problem we are facing with Internet Explorer 11 and Salesforce/Merchantforce.  The problem is that IE11 does not accept how Salesforce is processing AJAX calls to submit data, which generates an error in the console.

Here is the error message:

Unable to get property 'Submit' of undefined or null reference

And the html element that is generating this error:
<select  id="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" name="pageId:j_id5:Agreement:j_id9:j_id10:j_id12" onchange="A4J.AJAX.Submit(&#39;pageId:j_id5&#39;,event,{&#39;similarityGroupingId&#39;:&#39;pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13&#39;,&#39;parameters&#39;:{&#39;pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13&#39;:&#39;pageId:j_id5:Agreement:j_id9:j_id10:j_id12:j_id13&#39;} ,&#39;status&#39;:&#39;pageId:st1&#39;} )"><option value="">--None--</option><option value="Custom CAA">Custom CAA</option>
<option value="Standalone Agreement Document">Standalone Agreement Document</option>
<option value="Standard CAA">Standard CAA</option>
</select>

We are also seeing this same kind of error on some Salesforce pages, like the page describing Inbount/Outbound Change Sets the first time you go to those areas in the Setup sub-site.  The button to dismiss the introduction page are broken and produce similar error messages in IE11.

This is a critical problem as our company is about to roll out IE11 to everyone and these issues are going to impact our end-users who cannot be expected to use non-IE browsers.

We contact Salesforce and they suggested overwriting the meta tag with ApexPages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=9');

The controller for our page is manged and cannot be edited so I have tried adding it in the extension controller and making an new extension controller for just this, but that did not work.

Does anyone have any suggestions?

Thanks in advance.