• KevinP
  • SMARTIE
  • 1379 Points
  • Member since 2014
  • CodeFriar
  • Salesforce


Badges

  • Chatter
    Feed
  • 43
    Best Answers
  • 2
    Likes Received
  • 1
    Likes Given
  • 1
    Questions
  • 429
    Replies
HI,

We are using the standard Account page layouts. I was wondering what it would take to make a button conditionally show if a specific criteria was met. I am unable to find anything that allows a button to show up on a page layout conditionally. I know we can create custom page layouts and assign it per profile, but that is not the scenario. Ideally, based on the field values, the button should display or disappear. 

What is the recommended way to accomplish this?
trigger AlertTrigger on Alert__c (after update) {

System.debug('@@@@@@@@@@@');

    List<Account> acctlist = new List<Account>();
    Set<Id> acid = new Set<Id>();
       
       for(Alert__c ab:Trigger.New) {
           
           acid.add(ab.Account__c);
           
           system.debug('&&&&&&&&'+acid); 
       }
       
       Map<Id,Account> acct = new Map<Id,Account>([Select Id,Effective_Date__c,Region__c from Account where Id in :acid]);
           Set<Account> a = new Set<Account>();

    
          for(Alert__c b : Trigger.new){
     
              if(acct.containsKey(b.Account__c)) {
                   If(b.Type__c == 'New Client') 
        
                   {
                     
                      Account upd = acct.get(b.Account__c);
                        
                      If(upd.Relationship__c == 'Client' || upd.Relationship__c == 'Broker') 
                        { 

                          upd.Effective_Date__c = b.Effective_Date__c;
                          upd.Aetna_Region__c = b.Region__c;
                          a.add(upd);
            
                        }   
                  }

      }
   }
   
   
     acctlist.addAll(a);
    
     update acctlist;

}
So, I'm tasked with a project and need some general guidance. Basically, here is what I am trying to accomplish...

1. Our Org has a custom object that when created, I would like to fire off a trigger
2. The Trigger (or class that the trigger calls) would then find the subscriber (because they should already exist in Exact Target) and add that subscriber to an existing List in Exact Target. 

My question is... Can this be done with Apex code? I've read the documentation around adding subscribers to a list using the API but I haven't found any examples using APEX. I guess the other option would be to Invoke a Callout?

Thoughts? Thanks in advance for your time and effort.

Casey 
Hello, I'm seeing a lot here in the forum and in Salesforce documentation about offline (store and sync) functionality not being available in HTML5 mobile applications using the API unless they are hybrid mobile apps.  

However, this example application written using only HTML5 techology provides just that:  
https://github.com/ForceDotComLabs/mobile-ui-elements 

Example running on Heroku here:  https://sfdc-sobject-editor.herokuapp.com/  

The documenation for this application says it uses smartsync and smartstore for secure offline storage and sync but like I said I've seen everywhere else that this isn't possible. Can someone provide some insight on this?

Thanks
Help: I have created a Validation which will block the insertion of a contact if the contact is related to an account and has a mailing postal code (which has the API Name MailingPostalCode) different from the account's shipping postal code (which has the API Name ShippingPostalCode).
I tested the validation and I know it works because it gives the correct error message for this scenario however I am recieiving this error from Trail Head when I click on the green Check Challenge button :

There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []

2) I checked Data Management and I have a lot of space for creating a contact (1% or 99% free space)
For accounts I am at 93% full but I am not creating another account.

IS it the account percentage that needs reducing even though I am not creating another Account obejct at 93%?  Thanks for your help on this.
I've got my setSSKU() function setup to fire on the Model field, but I can't get my code to set the values on the Model and SKU(
<apex:inputField id="SSKU" value="{!objCase.Sensor_SKU__c}"/>
) fields. This code workw the the <apex:form> tag not sure why it's not working on this page.

JS
function setSSKU(){ var SSKUE = document.getElementById('{!$Component.pbMainLumidigm:SSKU}'); var model = document.getElementById('{!$Component.pbMainLumidigm:LuModel}').value; if(model=='M-Series'){ for(i=0; i < SSKUE.options.length; i++){ if(SSKUE.options[i].text.indexOf('V') >= 0){ SSKUE.options[i].style.display = 'none'; } if(SSKUE.options[i].text.indexOf('M') >= 0){ if(SSKUE.options[i].style.display == 'none'){ SSKUE.options[i].style.display ='block'; } } } } if(model=='V-Series'){ for(i=0; i < SSKUE.options.length; i++){ if(SSKUE.options[i].text.indexOf('M') >= 0){ SSKUE.options[i].style.display = 'none'; } if(SSKUE.options[i].text.indexOf('V')>=0){ if(SSKUE.options[i].style.display =='none'){ SSKUE.options[i].style.display = 'block'; } } } } }




Visualforce
<apex:pageBlock id="pbMainLumidigm" title="Case Edit" rendered="{!IsLumidigmRecType}"> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!saveCase}" onclick="return validateChannelPartner();"/> <apex:commandButton value="Save & Close" action="{!saveAndCloseCase}" onclick="return validateChannelPartner();"/> <apex:commandButton value="Cancel" immediate="true" action="{!cancelCase}"/> </apex:pageBlockButtons> <apex:pageBlockSection id="pbsFirst" title="Case Information" > <apex:pageBlockSectionItem > <apex:outputLabel value="Parent Case"></apex:outputLabel> <apex:inputField value="{!objCase.ParentId}"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlockSection> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Product"/> <apex:inputField required="true" value="{!objCase.Product__c}"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel value="Model"></apex:outputLabel> <apex:inputField id="LuModel" required="true" value="{!objCase.Model__c}" onchange="setSSKU()"/> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > </apex:pageBlockSectionItem> <apex:pageBlockSectionItem rendered="{!isRCNHRecType || ispivCLASS}"> <apex:outputLabel value="OS Language"/> <apex:inputField value="{!objCase.OS_Language__c}"/> </apex:pageBlock>

 
Hi,

As per the documentation, if you give a keyword in VF article list tag, the article that will be displayed on page will be sorted based on keyword relevance. I don't understand what it is meant with the "keyword relevance". What does that mean concrete? What are the criterias to be see as "related article" ?

Thanks
Goal: On custom object A insert create a Queue and create a separate custom object B that references the Queue we make.

Issue: To avoid the DML Exception the Queue has to be created using a @future method. This creates another issue where the @future code is being called after any of the source trigger and the following processes/flows that result from custom object A being inserted. The processes and flows need to execute after the Queue is created so we can access the Queue's values.

Has anyone else ran into this issue or possibly point me in the right direction?
Hi,
 I have created and scheduled daily and weekly reports for leads in my CRM. 
And able to get the mails daily and weekly for the reports.
The problem is report is sent as mail not excel or csv file attachments.
How to get scheduled reports as excel/csv file attchments in mails .
Any help is really appreciated.

Thanks,
Naveen.
Hello,

I'm trying to perform a simple Upsert operation with a trigger on the AdditionalNumber object (related to the Call Center stuff).

However, I'm getting the error message:
DML not allowed on AdditionalNumber

I've checked the objects documentation available here:
https://www.salesforce.com/developer/docs/api/Content/sforce_api_objects_additionalnumber.htm
It seems it does support an upsert call.

My code is below:
trigger UpdateCallCenter on User (after insert, after update, before delete) {
	if (Trigger.isAfter) {
		if (Trigger.isInsert || Trigger.isUpdate) {
			AdditionalNumber[] insertNumber = new List<AdditionalNumber>();

			for (User u : Trigger.new) {
				AdditionalNumber aN = new AdditionalNumber(Name = u.Name, Phone = u.Extension, CallCenterId = u.CallCenterId);
				insertNumber.add(aN);
			}
			
			upsert insertNumber;
		}
	}
}


Where am I going wrong here?

Many thanks!
Any ideas on a SFDC.com based native solution (not buying third pary app's) that can scan call records / notes and identify keywords (based on a word list) in the call records. The solutions goal is to identify inappropriate words in call notes (e.g the word bribe).

Possible Solution (Need help with solving point 4 or open to completely new ideas):

1. Create a table / List / object with the word list that needs to be scanned (e.g the word 'bribe' would be in that list)
2. Export existing call record data into a database and perform a SQL join with 'word list' to identify calls with the word bribe (this will be a monthly process)
3. Load the suspect calls back into SFDC for examination by say managers / auditors etc

4. Is there a way to highlight the words that were picked up by the SQL process in the call notes that were identified as suspect. Perhaps a SFDC formatting class that maybe available. This is the part that I dont have an initial solution for. The goal is to make it easier for a manager to know which word caused the call note to be flagged without having to manually scan for words in the call note.

Also although this is not ideal are you aware of any third party solutions that can do this? 
The issue we are encountering in that when making an HTTP Request, we immediately receive an System.CalloutException: Exceeded max size limit of 3000000. This issue is not occurring with the same code in the org's sandbox. In the sandbox, the call is successful and returns data as expected. But in the production instance, we constantly receive this error. I have checked the heap size prior to making the callout and it is 5406 bytes in size, well within the 3MB size limit. This is being reported in both the sandbox and in production. All other governor limits are well within limits. There are two HTTP requests that are made before the call that causes the error (to authenticate, etc.) so it is very confusing why this error is occurring, especially since it works just fine in the sandbox.

Please help.
Hi All,

I want to know about integration. What is Integration? How to use Integration in SFDC?
Please help me
I have a JS include script on my page

<apex:includeScript value="{!URLFOR($Resource.ValidationsJS)}" />
If I run the page as normal user it works fine, same page I am running as community user it didnot working. I checked the URL and found this issue
Normal user resource url - https://ebm--testatom.cs20.my.salesforce.com/resource/1422292766000/ValidationsJS
Community user url - https://testatom-attpartnerexchange.cs20.force.com/resource/1422292766000/ValidationsJS
I have a visualforce page that displays user contribution by CreatedById. Here is my controller code:
public List<AggregateResult> getTop6Contributors()
    {
        return [SELECT CreatedById, CreatedBy.Name Name  FROM Idea group by CreatedById, CreatedBy.Name order by count(CreatedById) desc limit 6];
    }
How do I display on my page the number of records a user has submitted?

Thanks!
 
Hello,

I´ve to make a little funcionality where oAuth is used and after googling it I don´t know if I have an enormous problem or not problem at all.

Every information I find is related to authentication from the salesforce side but what I have to do is authenticate an external callout with an external oAuth endpoint.

It can be resumed this way:

External someone call myHttpPOST apex class method(which NOT includes oAuth flow)

This external wants me to authenticate his request so gives me an oAuth Url which I´ll have to request(POST ay ay), depending of the response, I´ll generate an adecuate response to the original request to my POST apex rest.

Then, I´ll have a POST apex method which receive a request and inside of my method I´ll have to make a POST request to an external URL because cannot have two apex post methods in the same class.

As I said, I´m not sure if I understood a word or I´m finding problems where there are not.

Thanks, regards

 
Hi,

I have a requirement to build an Event Registration App for IPADs with following:-

1) The first Page should have 3 fields - Presenter, Event Name, Event Date. Once the presenter chooses all 3, 2nd page should come up.
2) The 2nd Page should capture the Name, ph no, Person ID, email, etc of the person registering. This should be save in Salesforce in a Custom object. Any new records being inserted for this custom object should also trigger a lead creation.
3) If the person registering is an existing contact and enters his Person ID his details should be auto filled.
4) Once Custom object Detail page should also have a refence to the lead created for the record.

How can I go about implementing this? Salesforce login should not be required for this.

Is is possible through lightning Or will I have to go for Mobile SDK Dev?

Thanks,
Vandana
Hello,
I'd like to enable Order to Opportunity creation feature in my dev org. 
Since I can no longer open a case with support, how do I request it?

Thanks
  • January 22, 2015
  • Like
  • 0
Is it possible to use and IF statement when displaying date from a LIST using apex:column.  In my example below, I want to check the value of Monday_Date and if it is in a specific month, display the "Monday" field; if not, then don't display the "Monday" field.

In my Data set, there is a field called "tec.Monday_Date__c" which I don't display on the page.  I would like to check the value of the "tec.Monday_Date__c" and if it equals a certain month, then display the data in the "tec.Monday__c" field; if not, then display nothing.

In psuedo-code, I would like to do this:

If (MONTH(tec.Monday_Date__c) = MONTH(tec_Start_date__c),
   Then   <apex:column width="10" value="{!tec.Monday__c}"/>
    Else   don't display the value for that column.

Is that possible?

 
<apex:pageBlockSection title="Billable Docket Report" columns="1" collapsible="False">Test
                <apex:pageBlockTable value="{!TEList}" var="tec">
                    <apex:column width="30" value="{!tec.Functional_Area__c}"/>
                    <apex:column width="20" value="{!tec.Standard_Activities__c}"/>
                    <apex:column value="{!tec.Activity_Other__c}"/>
                    <apex:column width="10" value="{!tec.Project__c}"/>
                    <apex:column width="10" value="{!tec.Contract__c}"/>
                    <apex:column width="10" value="{!tec.Monday__c}"/>
                    <apex:column width="10" value="{!tec.Tuesday__c}"/>

 
I have a custom object called "Project" that looks up to the object "Account" and I would like to create a Trigger that simply tells me how many "Projects" are linked to that specific "Account". Im just looking for someone to point me in the right direction.

Any help would be greatly appreciated.
Good day Ladies and Gents.

I lay before you the fruit of many days of frustration, labor and tears, begging for your help.

There are a few moving parts here, so let me introduce them one by one, with nicknames.

TheVisualForcePage - A humble visualforce page, attached to standard controller User, with a custom extension.

TheVFExtensionCtrl - A braggadocious apex class, who wants the world to know how awesome it is(n't).

TheVFComponentOfDoom - A visualforce component with a custom Controller that exposes two very insubordinate Command buttons. In our case, this component exists to provide a re-usable "delete" button, associated logic and general frustration.

TheVFComponentCtrl - An apex class whose sole purpose in life is to delete an F'ing record. Like the fat kid at primary school sports day, it's main issue is that nobody calls on it. (and therein lies our problem)

To set the stage with these moving pieces, we should consider that the Visualforce page displays, depending on mode, a list of either makes, models or years of cars owned by the given user. Because in my fictional world, users may own multiple Ferrari F12 Berlinetta's (different colors of course.) We can safely assume that if one were to navigate to Farrari, and then Berlinetta, we would see at least one record displayed on our VF page. (2013 of course). These records are displayed in a custom list view format created by using an Apex:Repeat tag.

It's here where we discover our first problem. The list view has, as it's last column a series of "actions" like: "Sell", "Delete" (dear god, who would ever delete a Farrari f12???) and edit. Sell and Delete are command buttons exposed via our handy components. To simply this issue, lets pretend we only have a delete button.

Now, to the untrained, unsuspecting eye a visualforce component, with it's own controller invoked on a page during an Apex:Repeat loop doesn't sound all that complicated. Sure there's the issue of passing in an ID to the logic of the component controller, but that's time-tested, mother approved. Indeed, I thought I was, well, done with this until ...

As it turns out, pressing the delete button has a very curious set of consequences in this setup, consequences I can not fully explain, nor fix.

When you click on the delete command button, the page refreshes (yay, i want that!) However:

Detailed logging shows that the master vfpage's associated controller extension's constructor is executed. Without error
That the component's deleteThisCar method is Never invoked.
Visually, the page state has been lost. What do I mean? I mean that the page that was displaying years of Ferrari F12 Berlinetta's is now just blank, showing only the headers of the listview.

Not to be outdone by an overgrown java app, I've tried the following approaches:

Updating my code to use apex:ActionRegion tags around the components
Tried every damn combination of reRender on the command buttons. Curiously, this had the effect of not reloading the page, and not calling my apex method.
I said, F-IT loudly and refactored the code to not use a component -- invoking an action method directly on the master controller, but this also failed! causing the page to reload, without my action method being invoked
I have slept on the problem. (no joke, this usually works for me. I wake up with the answer.)
I have asked Co-workers to look at it. They suggested the actionRegion bit.
I tried giving up on my trusty commandButtons attempting to use a standard input button with an ActionFunction -- Curiously, this invokes the constructor of my component controller, but not the actual delete function.

Suffice it to say, that overgrown java app is raining on my day.

This feels like somehow the wrong form is being submitted, which is distinctly maddening because i've also rewritten the master vf page such that it had 2 forms (search in header, main page form) and 5 forms (Search in header, 1 form per "mode") Neither has worked.

I realize that it'd be hypocritical in the extreme if I posted this question without some kind of code attached, so here's the component and it's extension. The VF page itself is quite lengthy and I've not finished "sanitizing" it for public consumption.
 
<apex:component controller="ACE_DeleteCarCmpCtrl" allowDML="true">
<apex:attribute name="tv"
    description="ID of the Car model and year to display controls for."
    type="Id"
    required="false"
    assignTo="{!CarVersionId}"
/>
<apex:attribute name="t"
    description="ID of the Car model to display controls for."
    type="ACE_Track__c"
    required="false"
    assignTo="{!Car}"
/>


    <apex:outputPanel layout="block" id="theoutputpanel">
    <apex:actionRegion >
    <!-- <apex:actionFunction name="sayHello" action="{!deleteTrackOrVersion}" rerender="TrackVersionsForSelectedTrack" /> -->
        <apex:commandButton action="{!deleteCarOrYear}"
            value="Delete Car"
            rendered="{!IF(ISNULL(Car), false , true)}"
            styleClass="btn btn-sm btn-default"
            />
        <!-- <input type="button" class="submit" onclick="sayHello"/> -->
        <apex:commandButton action="{!deleteCarOrYear}"
            value="Delete Car Version"
            styleClass="btn btn-sm btn-default"
            rendered="{!IF(ISNULL(CarVersionId), false , true)}"
            rerender="nothing"
            />
    </apex:actionRegion>
    </apex:outputPanel>
</apex:component>
and the controller for it:
public with sharing class ACE_DeleteCarCmpCtrl {

Public ACE_Car_Version__c carVersion {get; set;}
Public Id carVersionId  {get; set { carVersionId = value; }}
Public ACE_Car__c car {get; set;}

public ACE_DeleteCarCmpCtrl() {
    system.debug('$$$$$$$$$$$$$$ : ' + ApexPages.currentPage().getParameters());
}

public PageReference deleteTrackOrVersion() {
    system.debug('************* : ' + ApexPages.currentPage().getParameters());
    try {
        if (car != null && carVersion != null) {
            throw new ACE_contentManagementLib.ContentManagementException('Both car and carVersion cannot be populated when invoking this component');
        } else if (carVersion == null && car == null) {
            throw new ACE_contentManagementLib.ContentManagementException('Both car and carVersion cannot be null when invoking this component');
        } else if (carVersion != null) {
            ACE_ContentManagementLib.deletecarVersion(carVersionId);
        } else if (car != null) {
            ACE_ContentManagementLib.deleteTrack(track);
        }
    } catch (ACE_ContentManagementLib.ContentManagementException e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
    }
    //return null;
    //Also tried null above. no joy.
    PageReference pageRef = new PageReference('/AwesomePage?id=' + UserInfo.getUserId() );
    system.debug('$$$$$$$$$$$$$$ : ' + ApexPages.currentPage().getParameters());
    pageRef.setRedirect(true);
    return pageRef;
}
}


 
  • February 10, 2015
  • Like
  • 2
Good day Ladies and Gents.

I lay before you the fruit of many days of frustration, labor and tears, begging for your help.

There are a few moving parts here, so let me introduce them one by one, with nicknames.

TheVisualForcePage - A humble visualforce page, attached to standard controller User, with a custom extension.

TheVFExtensionCtrl - A braggadocious apex class, who wants the world to know how awesome it is(n't).

TheVFComponentOfDoom - A visualforce component with a custom Controller that exposes two very insubordinate Command buttons. In our case, this component exists to provide a re-usable "delete" button, associated logic and general frustration.

TheVFComponentCtrl - An apex class whose sole purpose in life is to delete an F'ing record. Like the fat kid at primary school sports day, it's main issue is that nobody calls on it. (and therein lies our problem)

To set the stage with these moving pieces, we should consider that the Visualforce page displays, depending on mode, a list of either makes, models or years of cars owned by the given user. Because in my fictional world, users may own multiple Ferrari F12 Berlinetta's (different colors of course.) We can safely assume that if one were to navigate to Farrari, and then Berlinetta, we would see at least one record displayed on our VF page. (2013 of course). These records are displayed in a custom list view format created by using an Apex:Repeat tag.

It's here where we discover our first problem. The list view has, as it's last column a series of "actions" like: "Sell", "Delete" (dear god, who would ever delete a Farrari f12???) and edit. Sell and Delete are command buttons exposed via our handy components. To simply this issue, lets pretend we only have a delete button.

Now, to the untrained, unsuspecting eye a visualforce component, with it's own controller invoked on a page during an Apex:Repeat loop doesn't sound all that complicated. Sure there's the issue of passing in an ID to the logic of the component controller, but that's time-tested, mother approved. Indeed, I thought I was, well, done with this until ...

As it turns out, pressing the delete button has a very curious set of consequences in this setup, consequences I can not fully explain, nor fix.

When you click on the delete command button, the page refreshes (yay, i want that!) However:

Detailed logging shows that the master vfpage's associated controller extension's constructor is executed. Without error
That the component's deleteThisCar method is Never invoked.
Visually, the page state has been lost. What do I mean? I mean that the page that was displaying years of Ferrari F12 Berlinetta's is now just blank, showing only the headers of the listview.

Not to be outdone by an overgrown java app, I've tried the following approaches:

Updating my code to use apex:ActionRegion tags around the components
Tried every damn combination of reRender on the command buttons. Curiously, this had the effect of not reloading the page, and not calling my apex method.
I said, F-IT loudly and refactored the code to not use a component -- invoking an action method directly on the master controller, but this also failed! causing the page to reload, without my action method being invoked
I have slept on the problem. (no joke, this usually works for me. I wake up with the answer.)
I have asked Co-workers to look at it. They suggested the actionRegion bit.
I tried giving up on my trusty commandButtons attempting to use a standard input button with an ActionFunction -- Curiously, this invokes the constructor of my component controller, but not the actual delete function.

Suffice it to say, that overgrown java app is raining on my day.

This feels like somehow the wrong form is being submitted, which is distinctly maddening because i've also rewritten the master vf page such that it had 2 forms (search in header, main page form) and 5 forms (Search in header, 1 form per "mode") Neither has worked.

I realize that it'd be hypocritical in the extreme if I posted this question without some kind of code attached, so here's the component and it's extension. The VF page itself is quite lengthy and I've not finished "sanitizing" it for public consumption.
 
<apex:component controller="ACE_DeleteCarCmpCtrl" allowDML="true">
<apex:attribute name="tv"
    description="ID of the Car model and year to display controls for."
    type="Id"
    required="false"
    assignTo="{!CarVersionId}"
/>
<apex:attribute name="t"
    description="ID of the Car model to display controls for."
    type="ACE_Track__c"
    required="false"
    assignTo="{!Car}"
/>


    <apex:outputPanel layout="block" id="theoutputpanel">
    <apex:actionRegion >
    <!-- <apex:actionFunction name="sayHello" action="{!deleteTrackOrVersion}" rerender="TrackVersionsForSelectedTrack" /> -->
        <apex:commandButton action="{!deleteCarOrYear}"
            value="Delete Car"
            rendered="{!IF(ISNULL(Car), false , true)}"
            styleClass="btn btn-sm btn-default"
            />
        <!-- <input type="button" class="submit" onclick="sayHello"/> -->
        <apex:commandButton action="{!deleteCarOrYear}"
            value="Delete Car Version"
            styleClass="btn btn-sm btn-default"
            rendered="{!IF(ISNULL(CarVersionId), false , true)}"
            rerender="nothing"
            />
    </apex:actionRegion>
    </apex:outputPanel>
</apex:component>
and the controller for it:
public with sharing class ACE_DeleteCarCmpCtrl {

Public ACE_Car_Version__c carVersion {get; set;}
Public Id carVersionId  {get; set { carVersionId = value; }}
Public ACE_Car__c car {get; set;}

public ACE_DeleteCarCmpCtrl() {
    system.debug('$$$$$$$$$$$$$$ : ' + ApexPages.currentPage().getParameters());
}

public PageReference deleteTrackOrVersion() {
    system.debug('************* : ' + ApexPages.currentPage().getParameters());
    try {
        if (car != null && carVersion != null) {
            throw new ACE_contentManagementLib.ContentManagementException('Both car and carVersion cannot be populated when invoking this component');
        } else if (carVersion == null && car == null) {
            throw new ACE_contentManagementLib.ContentManagementException('Both car and carVersion cannot be null when invoking this component');
        } else if (carVersion != null) {
            ACE_ContentManagementLib.deletecarVersion(carVersionId);
        } else if (car != null) {
            ACE_ContentManagementLib.deleteTrack(track);
        }
    } catch (ACE_ContentManagementLib.ContentManagementException e) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, e.getMessage()));
    }
    //return null;
    //Also tried null above. no joy.
    PageReference pageRef = new PageReference('/AwesomePage?id=' + UserInfo.getUserId() );
    system.debug('$$$$$$$$$$$$$$ : ' + ApexPages.currentPage().getParameters());
    pageRef.setRedirect(true);
    return pageRef;
}
}


 
  • February 10, 2015
  • Like
  • 2
HI,

We are using the standard Account page layouts. I was wondering what it would take to make a button conditionally show if a specific criteria was met. I am unable to find anything that allows a button to show up on a page layout conditionally. I know we can create custom page layouts and assign it per profile, but that is not the scenario. Ideally, based on the field values, the button should display or disappear. 

What is the recommended way to accomplish this?
Hi
My requirement is to bind recordtypes to an picklist and display in visual force page
I have the code show in this post.
public with sharing class recordtypepicklist
{
   public list<SelectOption> getRecordTypes()
   {
    list<SelectOption> options = new list<SelectOption>();
    
    for(RecordType sRecordType:[select ID,Name from RecordType where SObjectType='Contact'])
    {
     options.add(new SelectOption(sRecordType.ID,sRecordType.Name));
    }
     return options;
  }  
}
I am getting an error as Error: Compile Error: Variable does not exist: ID at line 9 column 38
Its coming from the statement inside the for loop.

Pls let me know how to resolve this.

pooja

 
I need for a field on the contact Call_Status__c to be updated to the picklist value "0E" when the task with the subject Task for Call 0A is marked completed.  Is there a way to do this with process builder or with workflows?  
While trying to use the query editor in developer console.

"SELECT ID FROM ACCOUNT"

It throws an erorr saying "This session is not valid for use with the REST API". Any idea what excatly tthe issue here. Earlier it workerd fine.
The same problem when i click on "Open" dialog of developer console and select objects.

"CANNOT LOAD OBjects.This session is not valid for use with the REST API"
I have a managed package installed that starts a Batch job. In my custom code I have implemented a Future method. When the batch job starts it updates my object and invokes the trigger that calls the future method. I would like to call the Future method only when its a normal operation and not a Batch operation. I  intend to use the System.isBatch() property to determine whether its a Batch operation. Since the Batch job is in the managed package I am not sure whether the variable will return a "True" value in my custom code. Has anyone encountered such an case ?
i have 3 objects   Child__c is junction object , ParentA__c is master obj, Parentb__c master object.

so child__c (Many to Many relation ship) is junction object bitween ParentA__c and ParentB__c
in child__c i have 2 date fiels Startdate, enddate
while createing a junction object record need to maintain uniqness using ParentA__c ,ParentB__c and range of Startdate, enddate
example :  dd/mm/yyyy
    Record1: startdate  10/06/2016  enddate 10/07/2016  save record sucessfully          
     Record2: startdate  10/06/2016  enddate 02/07/2016  need to give error message 
      Record3: startdate  20/06/2016  enddate 20/07/2017  save record sucessfully
     Record4: startdate  20/06/2016  enddate 01/07/2016 need to give error message 

for this i wrote below sample code please help me bulkyfy

trigger Jundupcheck on Child__c (before insert) {
for (Child__c  ci : trigger.new) {


     
// We only care if there is one record<br>      
List<Child__c> resultList = [SELECT id,Name,Enddate__c,StartDate__c,(selected id)  FROM Child__c  WHERE  ParentA__c = :ci.ParentA__c AND   ParentB__c = :ci.ParentB__c and  ( (StartDate__c >= :ci.StartDate__c AND StartDate__c <= :ci.EndDate__c) OR (endDate__c  >= :ci.StartDate__c AND endDate__c  <= :ci.endDate__c) )  ];
                     
            // Raise the error back if any records found    
            
            if (resultList.size()>0) {
             ci.addError('Duplicate record, a Affisiation already exists for that combination');    
             }  }

}
  • May 10, 2016
  • Like
  • 0
Hi All,

I need to change the status of a picklist field to synced whenever the account id is updated for external system.
Kindly Help

Thanks!!
Hi All,

I want to connect external system using External Data Sources.
Please check the following screen shots.
User-added image

User-added image

After that what are the steps need to connect external system. How can i check whether the system is connected or not with other system.

Please let me know with appropriate information.

Appriciate your response.


Thank you
Rakesh.S
What is the best way to create a date/time field which doesnot automatically change date/time according to logged-in user's timezone?
For example, if User1 (PST) sets the value in a date/time field as "01/01/2016 4:00 PM", then User2 (EST) should see same value in that field and not "01/01/2016 7:00 PM".
We tried using a text field and stamp this date/time on it, but the sorting on this field doesn't work.
Is there any other option?
Important requirement is - that the sorting should work properly and should be based on date/time value.
  • January 29, 2016
  • Like
  • 0
Hello All,
I have been banging my head trying to write the test class for the below code snipet. Appreciate anybody's help in this regard.
 
public class XYZ_RedirectToOptionsPageController {

    public XYZ_RedirectToOptionsPageController(ApexPages.StandardController controller) {

    }

    
    String callerPage;
    String configRequestId;
    public String id {get;set;}
    String detailCallerPage;
    String flow;
    public String refererStr { get;set; }
    public String liteItemId { get;set; }
    
    
    public XYZ_RedirectToOptionsPageController() {
        callerPage = ApexPages.CurrentPage().getParameters().get('callerPage');
        configRequestId = ApexPages.CurrentPage().getParameters().get('configRequestId');
        id = ApexPages.CurrentPage().getParameters().get('id');
        detailCallerPage = ApexPages.CurrentPage().getParameters().get('detailCallerPage');
        flow = ApexPages.CurrentPage().getParameters().get('flow');
        refererStr = ApexPages.currentPage().getHeaders().get('Referer');
        System.debug('Id'+id);
        liteItemId = [Select Id from ABC_Config2__LineItem__c where ABC_Config2__ConfigurationId__c = :id 
            AND ABC_Config2__IsPrimaryLine__c = true 
            AND ABC_Config2__LineType__c = 'Product/Service' Order By Id desc Limit 1 ].Id;
         System.debug('liteItemId'+liteItemId);        
    }
    
    public void executeLineItemsLogic() {
       if(String.isBlank(id)) return;
       List<ABC_Config2__LineItem__c> lineItemList = [SELECT Id, ABC_Config2__LineType__c, ABC_Config2__ChargeType__c, ABC_Config2__LineStatus__c, 
                ABC_Config2__EndDate__c, ABC_Config2__AssetLineItemId__c, ABC_Config2__AssetLineItemId__r.ABC_Config2__EndDate__c,
                ABC_Config2__PriceType__c, ABC_Config2__AssetQuantity__c, ABC_Config2__ConfigurationId__c,
                ABC_Config2__AssetLineItemId__r.ABC_Config2__ProductId__c, ABC_Config2__Quantity__c, 
                ABC_Config2__AttributeValueId__c, XYZ_Amend_Reason__c, 
                ABC_Config2__AssetLineItemId__r.ABC_Config2__Quantity__c, 
                ABC_Config2__AssetLineItemId__r.XYZ_Maximum_Licenses__c, BundleLineStatus__c,
                ABC_Config2__PriceListItemId__c, ABC_Config2__PriceListItemId__r.ABC_Config2__PriceType__c 
                FROM ABC_Config2__LineItem__c WHERE ABC_Config2__ConfigurationId__c = :id
                AND ABC_Config2__LineStatus__c = 'Existing' AND ABC_Config2__PriceListItemId__c != null
                AND ABC_Config2__AssetLineItemId__c != null AND BundleLineStatus__c = 'Amended'
                ORDER BY ID];

       if(lineItemList.isEmpty()) return;  
      
       for(ABC_Config2__LineItem__c lineItem : lineItemList) {
           if(lineItem.ABC_Config2__AssetQuantity__c < lineItem.ABC_Config2__AssetLineItemId__r.XYZ_Maximum_Licenses__c) {
               
               lineItem.ABC_Config2__Quantity__c = lineItem.ABC_Config2__AssetLineItemId__r.XYZ_Maximum_Licenses__c;
               lineItem.ABC_Config2__AssetQuantity__c =  lineItem.ABC_Config2__Quantity__c;
               lineItem.XYZ_Amend_Reason__c = null;
           }
       }
       
       update lineItemList;      
       
       
    }
    
    //action method to execute update logic and redirect to the option page
    public pageReference redirectToOptionPage() {
        executeLineItemsLogic();
        
        PageReference optionsPage = Page.ABC_Config2__ConfigureBundle;
        //optionsPage.getParameters().put('callerPage', callerPage);
        optionsPage.getParameters().put('configRequestId', configRequestId);
        optionsPage.getParameters().put('id', liteItemId);
        //optionsPage.getParameters().put('detailCallerPage', detailCallerPage);
        //optionsPage.getParameters().put('flow', flow);
         
        return optionsPage;
    }
}

 
I am encrypting a message using  Crypto.decryptWithManagedIV() method. Let my key be:   Wr/wa0vAe9RNmiMr 
This is the encryption and decryption process:
 
Blob cryptoKeyBlob = Blob.valueOf('Wr/wa0vAe9RNmiMr');
Blob msgBlob = Blob.valueOf('my message to be encrypted');
Blob encryptedMsgBlob = Crypto.encryptWithManagedIV('AES128', cryptoKeyBlob, msgBlob);
String encryptedMsgString = EncodingUtil.base64Encode(encryptedMsgBlob);
 
Blob keyBlob = Blob.valueOf('Wr/wa0vAe9RNmiMr');
Blob encryptedMsgBlob = EncodingUtil.base64Decode(encryptedMsgString);
Blob decryptedMsgBlob = Crypto.decryptWithManagedIV('AES128', keyBlob, encryptedMsgBlob);
String decryptedMsgString = decryptedMsgBlob.toString();

The encryption code lives in a different class and so does the decryption code.

Here is the issue. When I directly use the key in the code it works. But since referring a key in the code is not a good process I am using a custom setting to store it. But when the key is read from the custom setting and used in the code it throws an error saying: 
Input length must be multiple of 16 when decrypting with padded cipher

I debugged the code and it seems the key is read as it is and there is no change. I do not understand what is going wrong. Any help will be much appreciated.
Hi,
I need to generate XML file every month from different custom object with a hug data more than 10000 records. I wonder which way is best to
Generate XML:
1- Visualforce page and apex
2- Dom library 
3- XmlStreamWriter class


Any help would be appreciated!
Ahmad Amiri
trigger AlertTrigger on Alert__c (after update) {

System.debug('@@@@@@@@@@@');

    List<Account> acctlist = new List<Account>();
    Set<Id> acid = new Set<Id>();
       
       for(Alert__c ab:Trigger.New) {
           
           acid.add(ab.Account__c);
           
           system.debug('&&&&&&&&'+acid); 
       }
       
       Map<Id,Account> acct = new Map<Id,Account>([Select Id,Effective_Date__c,Region__c from Account where Id in :acid]);
           Set<Account> a = new Set<Account>();

    
          for(Alert__c b : Trigger.new){
     
              if(acct.containsKey(b.Account__c)) {
                   If(b.Type__c == 'New Client') 
        
                   {
                     
                      Account upd = acct.get(b.Account__c);
                        
                      If(upd.Relationship__c == 'Client' || upd.Relationship__c == 'Broker') 
                        { 

                          upd.Effective_Date__c = b.Effective_Date__c;
                          upd.Aetna_Region__c = b.Region__c;
                          a.add(upd);
            
                        }   
                  }

      }
   }
   
   
     acctlist.addAll(a);
    
     update acctlist;

}
HI I have developed an external application which using SOap to get contents from Salesforce. Soap call sometimes is getting "couldn't connect to host", which is quite critical as that causing my application to break.
When trying to upload a cahnge set from a sandbox to another sandbox I receive the following:

The following outbound change set upload failed due to a system error:

Change set: Objects (04tK0000000EJkB)
Organization: Dev (Developer Sandbox) (00DK000000XNi6a)
User: Swift River (005A0000000Z2or)
Error Number: 1722076013-80155 (245827274)

Please try to upload your change set again. If it does not succeed, contact Customer Support and provide the error number listed above.

Both sandboxes are using the same version (Winter '16) and the target sandbox is properly configured to receive the change set from the sending org.

Following the instructions in the error mssage I attempted to open a case with Salesforce support, but you cannot do that as the proper category is Developer Support and I cannot open a developer support case using the help system. So I opened another type of case, assuming that Salesforce would want to know that there is a problem with the system. Nope. The response was that I should post here. Does anybody here have access to the Salesforce system error code that might shed some light on the issue? 

Lest anyone wonder, I've been building outbound change sets since they were first implemented.

Park
Hi there

I've been trying to understand if I'm mistaken or not.

According to the help, (https://developer.salesforce.com/docs/atlas.en-us.securityImplGuide.meta/securityImplGuide/fields_about_encrypted_fields.htm), 

Encrypted text fields:
Are not available for: Salesforce Classic Mobile, Connect Offline, Salesforce for Outlook, lead conversion, workflow rule criteria or formulas, formula fields, outbound messages, default values, and Web-to-Lead and Web-to-Case forms.

However, I tried and I am able to send out encrypted text fields in my outbound message.  It is true I can't use it in workflow rule criteria or formula, but I can send out those encrypted fields.

Is it the documentation that hasn't been updated yet?

Thanks
King
Hi All,

We have created a XML feed with a SOQL and XML creation code and exposed thru a public site. Its working fine. Problem is if a record is added / modified it will some times show up immediately in XML feed link or some times it takes 10 mins to show the changes.

Any way we can reduce the time delay of the refresh?

Our clients are using this XML feed to populate their html code so, they are claiming that our feed is not real time.

Any comments in this direction will be great.

Thanks,
VC.
+1 (615) 266.1229
vidya.c@targetrecruit.net
Here my requirement is how to use the  
public static JSON2Apex parse(String json) {
        return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
        }
in my test class
my test class is following here
@istest(seeAllData = true)
public class allPatntsRcrdsCtrlr_Test
{
    public static JSON2Apex parse(String json) {
        return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class);
        }
   public static testmethod void test()
   {
      test.startTest();
     //inserting a record into the Account object
     Account acc = new Account();
     acc.Name = 'Sample Account';
     insert acc;
     
     //Inserting a Record into contact object
     Contact c = new Contact();
     c.Accountid = acc.id;
     c.Department = 'Testing';
     c.LastName = 'Test';
     insert c;
     
     //inserting a record into the Paitent object
     Patient__c pt = new Patient__c();
     pt.BlueStarID__c = 'fdsrt1224565';
     pt.Name = 'Sample'; 
     pt.Patient_First_Name__c = 'Test'; 
     pt.Patient_Id__c= 'sder45789'; 
     pt.Patient_Last_Name__c='Sample1'; 
     pt.ExternalID__c= 'sader22244578'; 
     pt.ProviderName__c= ''; 
     pt.SRType__c= 'Yes'; 
     pt.SampleCode__c= 'No'; 
     pt.ServiceRequestID__c= 12456789; 
     pt.UserID__c= 2456789;
     insert pt;
     //calling a pagereference in testclass
     PageReference pg = page.allPatientRecords;
     pg.getparameters().put('id',string.valueOf(pt.id));
     test.setcurrentpage(pg); 
     
     //calling the controller name
     allPatntsRcrdsCtrlr aprc = new allPatntsRcrdsCtrlr();
     //calling wrapperclass in test class
     
     
     //aprc.patlist  = pt;
     aprc.strBody = 'Plain';
     aprc.idv = 'Test';
     aprc.searchVal = '';
     aprc.searchFields = 'ProviderName';
     aprc.labeling = 'ProviderName';
     aprc.show = false;
     aprc.lstrecdstb1 = false;
     aprc.queryflds = true;
     aprc.pdfrendered = false;
     aprc.showmessage = true;
     aprc.wordRendered = true;
     aprc.xlRendered  = true;
     //calling methods in testcalss
     
      allPatntsRcrdsCtrlr aprc1 = new allPatntsRcrdsCtrlr();
     //calling wrapperclass in test class
     
     
     //aprc.patlist  = pt;
     aprc1.strBody = 'Rectangle';
     aprc1.idv = 'Test';
     aprc1.searchVal = '';
     aprc1.searchFields = 'BlueStarID';
     aprc1.labeling = 'BlueStarID';
     aprc1.show = false;
     
     aprc1.lstrecdstb1 = false;
     aprc1.queryflds = true;
     aprc1.pdfrendered = false;
     aprc1.showmessage = true;
     aprc1.wordRendered = true;
     aprc1.xlRendered  = true;
     
     allPatntsRcrdsCtrlr aprc2 = new allPatntsRcrdsCtrlr();
     //calling wrapperclass in test class
     
     
     //aprc.patlist  = pt;
     aprc2.strBody = 'Square';
     aprc2.idv = 'Test';
     aprc2.searchVal = 'Test';
     aprc2.searchFields = 'Patient_First_Name__c';
     aprc2.labeling = 'Patient_First_Name__c';
     aprc2.show = false;
     /*
     aprc2.lstrecdstb1 = false;
     aprc2.queryflds = true;
     aprc2.pdfrendered = true;
     aprc2.showmessage = true;
     aprc2.wordRendered = true;
     aprc2.xlRendered  = true;
     */
     allPatntsRcrdsCtrlr aprc3 = new allPatntsRcrdsCtrlr();
     //calling wrapperclass in test class
     
     
     //aprc.patlist  = pt;
     aprc3.strBody = 'square';
     aprc3.idv = 'Test';
     aprc3.searchVal = 'Sample1';
     aprc3.searchFields = 'Patient_Last_Name__c';
     aprc3.labeling = 'Patient_Last_Name__c';
     aprc3.show = false;
     
     aprc3.lstrecdstb1 = false;
     aprc3.queryflds = true;
     aprc3.pdfrendered = false;
     aprc3.showmessage = true;
     aprc3.wordRendered = true;
     aprc3.xlRendered  = true;
     
     
     aprc.clear();
     //aprc.patinfo();
     //aprc.PatientData();
     aprc.retrieve();
     
     //aprc.doSearch();
     //aprc.ExpXL();
    
     aprc.ExpPDF();
     aprc.ExpWord();
     aprc.getlabeling();
     aprc.getsearchFields();
     
      allPatntsRcrdsCtrlr.oAuthRecords ar = new allPatntsRcrdsCtrlr.oAuthRecords();
          ar.BlueStarID = '';
          ar.HubCode    = 'asd145789jjhgdrt';
          ar.PatientName = 'Pointing';
          ar.PatientFirstName = 'John';
          ar.PatientID   = 'serer45789dfh';
          ar.PatientLastName = 'Ricky';
          ar.ProviderName   = '';
          
          ar.SRType = 'Active';
          ar.SampleCode = 'Yes';
          ar.ExternalID = '1245gggtder214578';
          ar.ServiceRequestID = 20001457;
          ar.UserID  = 457896321;
      allPatntsRcrdsCtrlr.JSON2Apex ja = new allPatntsRcrdsCtrlr.JSON2Apex();
      ja.access_token = 'hfert45778969jhgt';
     List<Apexpages.Message> pageMessages = ApexPages.getMessages();
     test.stopTest();
   }
}

This functionality is working for a very long time and it stopped recently not sure why.

 

we have to create a user through apex and grant them customer portal access and they should be recieving a welcome email with their login credentials.

 

Please take a look at our existing code. Its' giving them the portal access but not sending the email,

 User portalUser = new User();
            portalUser.Alias = con.Name.substring(0,2)+ultility_GlobalFunctions.generateRandomString(3);
            portalUser.Username = con.Email;
            portalUser.FirstName = con.FirstName;
            portalUser.LastName =  con.LastName;
            portaluser.CommunityNickname = con.Name.substring(0,2)+ultility_GlobalFunctions.generateRandomString(5);            
            portalUser.Email = con.Email;
            portalUser.Cost_Center__c = 'None';
            portalUser.Country = 'USA';
            portalUser.Region__c = 'AMER';
            portalUser.ContactId = con.Id;
            portalUser.ProfileId = [select Id from profile where Name= 'Manager'].Id;
            //portalUser.UserRoleId = [select Id from UserRole where Name = :recordtype].Id;        
            portalUser.emailencodingkey='UTF-8';
            portalUser.languagelocalekey='en_US';
            portalUser.localesidkey='en_US';
            portalUser.timezonesidkey='America/New_York';
            
            Database.DMLOptions dlo = new Database.DMLOptions();
            dlo.EmailHeader.triggerUserEmail = true;
            dlo.EmailHeader.triggerAutoResponseEmail= true;
                
            
            try{
                portalUser.setOptions(dlo);         
                insert portalUser;     
     
            }catch( exception ed){              
            
            }  

 Please help...

  • November 12, 2013
  • Like
  • 0
Hi,
I have 1500 records in my account object. I want to print all these 1500 records with thte layout they appear as on a Print click.
Is this even possible in salesforce? Please help.
  • October 21, 2015
  • Like
  • 1