• gaiser
  • NEWBIE
  • 255 Points
  • Member since 2004

  • Chatter
    Feed
  • 9
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 62
    Replies

Hi,

 

We are working on email templates and we cannot figure out how to do the IF THEN properly. Does Salesforce has an 'OR' operator ?

 

Basically what we have is 3 checkboxes, when one or more is checked we want the code to show "GOOD" when none are checked then show "BAD"

 

The code below is obviously wrong,

 

{!IF((Opportunity.fullcatalog__c==FALSE) OR (Opportunity.custommanudiv__c=FALSE) OR (pportunity.contactme__c=FALSE), "GOOD", "BAD")}

 

We also tried the "CASE" statement, but it did not work.

 

Thanks in advance!

  • September 06, 2013
  • Like
  • 0

I wrote a class with a few functions that return account IDs based on a custom field.

 

public class ComplaintOperations{
    public static Id getaid(string client_id){
        //Try to find Account with matching client_id, with or without leading 0s. return Account ID if found, otherwise return null
        Account[] a = [find :client_id in all fields returning Account(Id,client_id__c where Client_Id__c like :client_id) limit 1][0];
        if (a.size() !=0){    
        	return a[0].id;}
        else{string othercid = '00'+client_id;
        	Account[] a2 = [find :othercid in all fields returning Account(Id,client_id__c where Client_Id__c like :othercid) limit 1][0];
            if(a2.size()!= 0){return a2[0].id;}
             else{return null;}
            }
    }
             
             
    public static Boolean isclientid(string client_id){
        if(getaid(client_id) == null){return false;}
        else{return true;}
    }
}

 It works just fine when i run it from the console:

system.debug(complaintoperations.getaid('0012345'));

 yields the correct ID.

 

But my unit tests:

@isTest
public class testComplaintOperations{
    
    static testMethod void testGetAid(){
        string cid = '999999999';
        Account a = New Account(Name='Daniel Sadster',client_id__c = cid,status__c = 'Active');
        insert a;
        system.assert(a != null);
        system.assertequals(a.id,ComplaintOperations.getaid(cid));
        System.assertequals(null,ComplaintOperations.getaid('123'));
    }
    static testMEthod void testisclient(){
    	string cid = '999999999';
        Account a = New Account(Name='Daniel Sadster',client_id__c = cid,status__c = 'Active');
        insert a;
        system.assertequals(Complaintoperations.isclientid(cid),true);
        system.assertequals(Complaintoperations.isclientid('pooppypants'),false);
    }
}

 Keep failing!

Apparently because the "find" statements in my class yield nothing.

Any ideas?

 

Hey folks!

I want to run a scheduled class right after a trigger has fired. This is my cron expression so far:

 

Datetime n = Datetime.now();
CRON_EXP = '0 ' + n.addMinutes(1).format('m') + ' ' + n.format('H') + ' ' + n.format('d') + ' ' + n.format('M') + ' ? '+ n.format('yyyy');

 

How do I modify this expression so that the code is only executed one time / once?

 

Thanks for your help

Josh :-)

It looks like the Code Coverage pages for my apex code now includes blank lines and commented out rows as "Un-covered" and highlights them in red.

 

Is anybody else noticing this? Is it a bug?

 

With thanks,

Andy

Hi guys,

 

I have a public checkout site in salesforce. And sometimes I recieve feedbacks from our customer that they got ssl error while visiting this page. The error is an SSL certificate issued error and I don;t how to deal with it. Caould anybody give me some advices to get rid of it? Thanks.

 

Is there a way to check if an Apex program is running asynchronously (e.g. through @future)?

I have been refactoring a large application recently and have began creating tests for the major components of the application today. I have been executing a single test through the Apex Test Excecution feature. Upon looking at the code coverage for a basic class, I found that many code comments, and blank lines ( only white space. ) were marked in red, indicating they are not covered. This is clearly an error, comments should always remain white. I verified this was adversely affecting code coverage by removing the comments, and re-running the test. The coverage increased by 2 percentage points.

Here is a screen shot of the code coverage stats showing comments and blank lines in red.  I believe the parsing issue may somewhat involve the multi-line SOQL query. When I place the query on one line some of the issues are corrected.

 

Code Coverage APEX Test Run

 

 

Is there a way to remove sidebars and headers within an iframe? I have a customized Opportunity page and I want to see the Opportunity shares. I can do this with an iframe, however, I could do without the header and sidebar. 

 

Thanks

 

Anyone know how to filter out the meta data xml files from the file list? I see a "*-meta.xml" file for each tigger, class, page, etc I've imported to the IDE... kinda annoying.
  • March 26, 2009
  • Like
  • 0
Since Winter 19 all SFDC Orgs I have access to (sandbox & production) started to return blank locationsNotCovered node in /tooling/runTestsSynchronous/ result
For example - a basic call with 1 test class like this: 
User-added image

Results in this response 
User-added image

Instead of exact uncovered lines - locationsNotCovered now contains an array of empty values.

Has anyone else come across this issue? How can this be reported to SFDC? I do not have access to the type of support which allows submitting a case to SFDC.
By the way - the problem is not "workbench" - java client (using WSC library) gets the same response.
  • November 06, 2018
  • Like
  • 0
Metadata API v29.

When using metadata retrieve() call to retrieve specificFiles e.g. MyClass.cls, MyPage.page or Contact.object system returns correct CreatedDate & LastModifiedDate for code files like MyClass.cls or MyPage.page but not for objects like Contact.object.

retrieve() call for Contact.object (and other objects) always returns current Date/Time instead of the real CreatedDate and LastModifiedDate.
So if I issue retrieve() call for Contact.object twice in a row I will get two different Create and LastModified dates.

Does anyone now a workaround for this?
  • March 06, 2014
  • Like
  • 1
Hi,

I have an object (Item__c) with picklist Status__c and two record types RT1,RT2
Status__c picklist is single-select and has following values: Value1, Value2,Value3
In record type settings I have
RT1: Value1 - the only value available for Status__c
RT2: Value2 - the only value available for Status__c

In my custom controller I preset Item__c.RecordTypeId in constructor such as when page is rendered I display RecordTypeId value as well as Status__c picklist as input value.

 
Code:
...
<apex:outputText value="{!Item__c.RecordTypeId}"/>
<apex:inputField value="{!Item__c.Status__c}"/>
...

 I expected that list of available values in Status__c picklist will be rendered according to the RecordType settings, i.e. if I set RecordTypeId=<ID-of-RT1> then  Status__c will display Value1 *only*.
But in reality it displays all values and also ignores Default value setting based on Record Type.
I am certain that RecordTypeId is set correctly because I can see it on the screen.

Am I doing something wrong and <apex:inputField> supposed to respect RecordType Settings or is it by design.
If by design, then what is the best way to display picklist values based on RecordType settings?

  • August 28, 2008
  • Like
  • 0
I am trying to create EmailTemplate from Apex Class (in Sandbox) but system complains in the line where I do
------------
insert mytemplate;
------------
Error message states: Compilation error: DML not allowed on setup entity

Apex Developer's Guide in section "SObjects That Do Not Support DML Operations" does not mention anything about EmailTemplate and hence I assume that creation of EmailTemplate is absolutely legal.

Is it a bug in the documentation or in SFDC Apex Compiler?

Has anyone else experienced similar problem?
  • December 06, 2007
  • Like
  • 0
Looks like a copy/paste related problem
https://na4.salesforce.com/soap/ajax/9.0/connection.js
method
sforce.Connection.prototype.writeHeader = function(writer, headerNs)

Code:
sforce.Connection.prototype.writeHeader = function(writer, headerNs) {
writer.startHeader();

writer.writeNamespace(headerNs, "sfns");

if (this.sessionId !== null) {
writer.writeStartElement("SessionHeader", headerNs);
writer.writeNameValueNode("sessionId", this.sessionId);
writer.writeEndElement("SessionHeader", headerNs);
}
if (this.organizationId !== null) {
writer.writeStartElement("LoginScopeHeader", headerNs);
writer.writeNameValueNode("organizationId", this.sessionId);
writer.writeEndElement("LoginScopeHeader", headerNs);
}
...
}
Notice code after
if (this.organizationId !== null)
condition.
It seems to me line 2 after the condition above shoule be
writer.writeNameValueNode("organizationId", this.organisationId);


 

  • March 16, 2007
  • Like
  • 0
Looks like method moveOption() from functions.js (ex. https://emea.salesforce.com/js/functions.js) incorrectly notifies sourceSelect about its content change
Currently it looks like
Code:
// notify the Select Elements that their contents have changed
...
if (sourceSelect["onchange"]) {
sourceSelect.onchange();
}

// remove selected values from the source, starting with the last one selected
for (var i = selectedIds.length - 1; i > -1; i--) {
sourceSelect.remove(selectedIds[i]);
}
Obviously call of sourceSelect.onchange() should be done after "sourceSelect.remove(selectedIds[i])" cycle, not before.
  • March 30, 2006
  • Like
  • 0
Metadata API v29.

When using metadata retrieve() call to retrieve specificFiles e.g. MyClass.cls, MyPage.page or Contact.object system returns correct CreatedDate & LastModifiedDate for code files like MyClass.cls or MyPage.page but not for objects like Contact.object.

retrieve() call for Contact.object (and other objects) always returns current Date/Time instead of the real CreatedDate and LastModifiedDate.
So if I issue retrieve() call for Contact.object twice in a row I will get two different Create and LastModified dates.

Does anyone now a workaround for this?
  • March 06, 2014
  • Like
  • 1

Hi,

 

We are working on email templates and we cannot figure out how to do the IF THEN properly. Does Salesforce has an 'OR' operator ?

 

Basically what we have is 3 checkboxes, when one or more is checked we want the code to show "GOOD" when none are checked then show "BAD"

 

The code below is obviously wrong,

 

{!IF((Opportunity.fullcatalog__c==FALSE) OR (Opportunity.custommanudiv__c=FALSE) OR (pportunity.contactme__c=FALSE), "GOOD", "BAD")}

 

We also tried the "CASE" statement, but it did not work.

 

Thanks in advance!

  • September 06, 2013
  • Like
  • 0

I come to know that to update Apex component it is required to use Metdatacontainer object with ApexClassMember/ApexTrigger member. In Force.com Tooling API Dev guide given all examples to use Metadatacontainer and updating ApexClassMember and other members, but there all given examples uses SOAP API.

 

In REST API only syntax and hints are provided for creating, deleting, describe but no implementation. I am able create a Metadatcontainer object and receive its id as response and by same way ApexClassMember, but don't know how to use it with Metadatacontainer.

 

My Question is how to include and work with ApexClassMember with Metadatcontainer or associating ApexClassMember/ApexTriggerMember with a Metadacontainer object using REST API?

  • September 04, 2013
  • Like
  • 0

I wrote a class with a few functions that return account IDs based on a custom field.

 

public class ComplaintOperations{
    public static Id getaid(string client_id){
        //Try to find Account with matching client_id, with or without leading 0s. return Account ID if found, otherwise return null
        Account[] a = [find :client_id in all fields returning Account(Id,client_id__c where Client_Id__c like :client_id) limit 1][0];
        if (a.size() !=0){    
        	return a[0].id;}
        else{string othercid = '00'+client_id;
        	Account[] a2 = [find :othercid in all fields returning Account(Id,client_id__c where Client_Id__c like :othercid) limit 1][0];
            if(a2.size()!= 0){return a2[0].id;}
             else{return null;}
            }
    }
             
             
    public static Boolean isclientid(string client_id){
        if(getaid(client_id) == null){return false;}
        else{return true;}
    }
}

 It works just fine when i run it from the console:

system.debug(complaintoperations.getaid('0012345'));

 yields the correct ID.

 

But my unit tests:

@isTest
public class testComplaintOperations{
    
    static testMethod void testGetAid(){
        string cid = '999999999';
        Account a = New Account(Name='Daniel Sadster',client_id__c = cid,status__c = 'Active');
        insert a;
        system.assert(a != null);
        system.assertequals(a.id,ComplaintOperations.getaid(cid));
        System.assertequals(null,ComplaintOperations.getaid('123'));
    }
    static testMEthod void testisclient(){
    	string cid = '999999999';
        Account a = New Account(Name='Daniel Sadster',client_id__c = cid,status__c = 'Active');
        insert a;
        system.assertequals(Complaintoperations.isclientid(cid),true);
        system.assertequals(Complaintoperations.isclientid('pooppypants'),false);
    }
}

 Keep failing!

Apparently because the "find" statements in my class yield nothing.

Any ideas?

 

Here is the information about this

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/sforce_api_calls_runtests_result.htm

 

 

 

My question is how can i call/query this object using APEX?

 

Hi,

 

I have a History Object with createdDate as DateTime data type which is in this format 2005-10-08T01:02:03Z

Now my requirement is that i need to get the current time with date in the format 2005-10-08T01:02:03Z and pass it on to the SOQL.

 

I have tried to dynamically get the current DataTime as shown below

 String str = DateTime.now().format('yyyy-MM-dd\'T\'hh:mm:ss\'z\'');

 

but the problem is that i cannot assign this string to my created datatime as shown below

SELECT Id
FROM Account
WHERE CreatedDate =: str

 

I have tried to print DateTime.now(), System.now() in the console but they all throw the output in this fashion - YYYY:MM:DD HH:mm::SS. 

 

Can i please know how do i resolve this or is there any function which can directly fetch me datetime in this format 2005-10-08T01:02:03Z.

 

Appretiate your help.

 

Thanks,

Hemanth

Is there anyway to get to the old developer console anymore?

 

The new one for simple things just straight up Blows Goats. It never works in Chrome for me have to goto Firefox, it's instanely slow and clumbsy. It's slowing down my development and I'm going to throw the monitor I keep it on out the window. 

 

Thanks!

  • March 06, 2013
  • Like
  • 0

public virtual interface Pair<T, U> {
    T getFirst();
    U getSecond();
    void setFirst(T val);
    void setSecond(U val);
    Pair<U, T> swap();
}

The above code from APEX guide does not compile with Error: Compile Error: type parameters not supported?

 

Thanks for the help!

Hi,

 

If I have to use destructivechanges.xml for removing couple of classes from org, do I need to specify those classes in package.xml in same directory. It is not clear from migration guide. Please clarify.

 

Thanks

Hello,

 

What happen to records like event, contacts owned by an user which is deactivated?

Thanks,

Hey folks!

I want to run a scheduled class right after a trigger has fired. This is my cron expression so far:

 

Datetime n = Datetime.now();
CRON_EXP = '0 ' + n.addMinutes(1).format('m') + ' ' + n.format('H') + ' ' + n.format('d') + ' ' + n.format('M') + ' ? '+ n.format('yyyy');

 

How do I modify this expression so that the code is only executed one time / once?

 

Thanks for your help

Josh :-)

It looks like the Code Coverage pages for my apex code now includes blank lines and commented out rows as "Un-covered" and highlights them in red.

 

Is anybody else noticing this? Is it a bug?

 

With thanks,

Andy

Hi guys,

 

I have a public checkout site in salesforce. And sometimes I recieve feedbacks from our customer that they got ssl error while visiting this page. The error is an SSL certificate issued error and I don;t how to deal with it. Caould anybody give me some advices to get rid of it? Thanks.

Hi

 

I want to remove all(say 100) classes from my org using ant. So i can not specify the name of individual class in destructiveChanges.xml file. Hence i tried to create it like below:


<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<version>20.0</version>
</Package>

 

But i am getting error "No ApexClass Named: * found"

 

can someone please help me on this?

 

Thanks in Advance!!!!

 

Is there a way to check if an Apex program is running asynchronously (e.g. through @future)?

I have a typical deployment scenario at my work place.
 
We have Perforce for Version control.
 
Here is the scenario:
 
A developer codes, customize or configure something in his dev org. He now checks in his changes to the version control repository called Perforce.
 
I have to do a automated deployment every night to query perforce for the latest changelist/Label dynamically and then deploy the changes to sandbox, prod etc. This one should be automated with no human interventions. Again this whole process of querying and then deploying should be automated. While querying i should be querying only the changed files based on a label or changelist and not all the files.
 
is there a way to handle this scenario and is there any reference for me to accomplish this?
 
 
Another question,
 
I have a folder that contains subfolders like objects, classes etc. can i do deployment using Ant migration tool without the package.xml file in it
Is the package.xml file really needed for any kind deployment.
 
This is a very critical req that has to be answered before noon. Please help me da.

Hi, I am trying to setup the secure web address so I can provide it to a banking service, they require this link to have https at the begining, however when I access my secure web address it crosses a line on the https indicating that there is unsecure content:

 

https://app-facturacion-incompany.force.com/colormelocoton

 

https wrong

 

I have verified that there is no unsecure content and tried with several VF pages and the problem persists, also verified that the option "force https" is checked, still nothing.

 

Any ideas how make this look something like this:

 

Https good

 

I would appreciate some help. Thanks!

 

-D