• JayNic
  • NEWBIE
  • 444 Points
  • Member since 2011

  • Chatter
    Feed
  • 13
    Best Answers
  • 3
    Likes Received
  • 1
    Likes Given
  • 37
    Questions
  • 90
    Replies
I have tried this code for custom button for single click email sending. Unfortunately It is not working and showing error. Could anyone tell me where I am doing wrong and correct me please.

Thank you.
location.replace('/email/author/emailauthor.jsp retURL=/{!Opportunity.Id}&p24="varunreddypenna@gmail.com,v.reddy@thegordiangroup.com"&template_id="00Xj0000000J8sI"&p3_lkid={!Opportunity.Id}&p3={!Opportunity.Name}&p26={!User.Email}&p5="penna.janareddy@gmail.com"&save=0')
User-added image
User-added image

 

I needed to make a visualforce email template so that I could select a language based on a field on my contact record. It is required to have the {!Case.Thread_Id} merge field in the subject line so it doesn't create a new case everytime a user responds. However in a visualforce email template it tells me it doesn't exist.

Error: Invalid field Thread_Id for SObject Case

 

This is my email header.  Is the Thread_Id merge field not available when using a visualforce email template?

 

<messaging:emailTemplate subject=" {!relatedTo.Thread_Id} {!$Label.Portal_Case_Comment_Subject} {!relatedTo.CaseNumber}" recipientType="Contact" language="{!recipient.Language__c}" relatedToType="Case">

Anyone have a good idea for a workaround?

 

Thanks,

 

Dahveed

Hi.

 

   I have written just a few triggers and was wondering if this trigger is absolutely fine or if it lacks something.. although the trigger is working when i am inserting single entry through the window.. was wondering if it would also work when using data Loader.

HI

 

I have a page that needs to do the occasional calculation then show the results afterwards which entails a section of the page to be rerendered. If the focus was within the rerendered area then the focus is lost. I want to put it back. I am aware that a lot of components that have an Action attribute also have a Focus attribute. Problem is I can't figure out how to tell it to return the focus to where it was. I am hoping that there is something like this:

 

focus="{!$CurrentPage.getComponentID.CurrentFocus}"

 

That would make life so easy. Not afraid of APEX or Javascript if they present a solution. Any and all help appreciated.

 

Regards

MellowRen

Hello, I wanted to know if you could tell me how can I validate that a person cant create a junction object twice using the same relationships. For example, I have a junction object between contacts and programs and i dont want people create the same junction object using a contact that is already with one program. I created a trigger to help me before insert and update but I havent been able to test it (**bleep** tests -_-) so I want to know if there is a way to make the information unique without using the trigger. Thanks

Hi there,

 

I am very new to Apex triggers....so new that this is the first one I have attempted that isn't from a workbook. Everyone has to start somewhere though I guess.

 

I assume that this will be quite simple and so I will describe my situation as best I can and hopefully, someone will have an idea on how I can solve my problem.

 

I have a custom object (Destiny products and services), this custom object has a lookup field to another custom object (product). When creating a new 'destiny product and service" I have made formula fields which autopopulate fields from the Product object, relating to which product the record creator chose from the Product lookup field.

 

This has all worked fine as I just needed a simple formula field, however the products and services have differing stages, types, etc depending on the product or service chosen. 

 

I attempted to accomplish this by creating a picklist field within each custom object which states the names of all the products or services, I then created dependant picklists in relation to what choice was made in the name picklist and then made this hidden. 

 

I want to make this as simple as possible for the user and so I intend to make it so that when the lookup field is selected, it will autopopulate the name picklist so it is the same as the lookup field and then the Destiny product or services record will have stages and type which will be related to the product chosen. 

 

I need to write an apex trigger which will set the picklist value in the products and services object, to be the same as the picklist option from the record chosen in the lookup field (product object).

 

Any help would be much appreciate, even advice on alternative and perhaps easier ways that this can be accomplished. I am sorry if this is difficult to understand.

 

Mikie

Hi All

    I have 2 custom objects A__C , B__c . Object B looks upto Object A.

 Now B has a field say "Revenue__c". A__c has a field "Total Revenue". I wanna write a trigger on B to update Total Revenue__c on A , upon addition,deletion or update of B record. Please help me with the outline of that triggger.

 

 

Thanks

I have a button on a visualforce page that will generate a report using a url in another window, similar to the code below:

 

<apex:commandButton value="Submit" action="{!controlleraction}"  onClick="window.open('/apex/VFPage');"/>

 

What I want to do is to stop the onClick event from happening if the controlleraction has an error.  Basically when they click the button I need to run some validations to make sure the report won't be blank or contain in correct data.  So I want to first run a validation routine in the controller, if it passes then I want the report to generate.  If not, I don't need the report to open; the controller method will return an error to the page.

 

 

Hello,

 

We have been using the Salesforce API for some time now. Recently we have encountered an issue in accessing fields of an entity, Contact.

 

While reading the contact information we used to fetch the values of 'HomePhone' and 'OtherPhone' along with other fields. However now when we try to get contact information, it is throwing an error with following message.

 

No such column 'HomePhone' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name.Please reference your WSDL or the describe call for the appropriate names.

 

The problem it seems here is, those fields (HomePhone and OtherPhone) are made disabled rather inaccessible possibly through 'Set Field-Level Security' option of the field.


Is this correct behavior?

  • If NO, what should happen? 
  • If YES, how to tackle this issue?

Please advise me.

 

Thanks
Ashish

  • May 29, 2013
  • Like
  • 0

We have an app that is made up of almost entirely custom objects. Creating a smoothe workflow for our users is vital for this app. I'm new to apex, but familiar with basic code writting.

 

Here are the relationships between the objects: (--< = 1 to many, M/D = Master/Detail)

 

Object_a --< Object_b --M/D--< Object_c

Object_a --M/D--< Object_d

 

When a user populates a date field on Object_c and saves, we'd like a date field on all related records on Object_d (i.e. all Object_d's records for that specific Object_a record) to be updated with the same value. 

 

Any help is appreciated.

Hi All, 

 I have requirement like .

I have one text box if user enters some text like 'AB' then it will search on Account,Contact and leads  objects .then it  shoud display values contanis 'AB'   in contact, account and Lead in Single pageBlock table?

 

  Search text:  'dynamic text' here is 'AB' then list should display like this 

 it should display in pageblocktable:

 

 

Objname  Name     City

 

Contact      abi           abudhabi

 

Account     test AB    chennai ab

 

 

Lead         abraham   raviab

 

 

Thanks,

 

 

Vicky

Hi,

 

I wanna be able to pass the CSV file to another class in order to process more records from the file since i have a governor for insert statements.

 

CODE:

 

public with sharing class UploadRecordUsingCSV {

    public UploadRecordUsingCSV(ApexPages.StandardController controller) {

    }

    
    public Blob FileRecords{get;set;}
    
    String[] LineNo= new String[]{};
    List<product_opportunity__c> AllUnit;
    
    Public Pagereference UploadFile()
     {
       system.debug('Enter');
       String FileData=FileRecords.toString();
       LineNo=FileData.split('\n');
       AllUnit = new List<product_opportunity__c>();
                system.debug('Entered****'+ AllUnit);
       for(Integer i=1;i<LineNo.size();i++)
        {
          product_opportunity__c pto = new product_opportunity__c();
          String[] ActualData=new String[]{};
          ActualData=LineNo[i].split(',');
          pto.Name = 'TEST';
          
          pto.OpportunityID__c = ActualData[0];
          pto.Part_Number__c = ActualData[1];
          pto.Vendor_Unit_Cost__c = double.valueOf(ActualData[2]);
          
          //AllUnit.add(pto);
          insert pto;
        }
       //insert AllUnit;
       return Null;
     }
}

 

 

Hey guys,
I'm trying to implement a regex, and I can't figure out what the hell I'm doing wrong and what to escape... I keep getting 'invalid characters sequence' in whatever I try.

Here is the regex: ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?

It will return me groups of the url parsed. I'm supposed to do something like the following:
Pattern myPattern = Pattern.Compile('^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?');
matcher myMatcher = myPattern.matcher(pUrl);
myMatcher.matches();

for(integer i = 0; i < myMatcher.groupCount();i++){
    system.debug(
	    myMatcher.group(i)
    );
}

I've tried backslash escaping the backslashes, double escaping, using Pattern.Quote(), murdering coworkers.... Nothing works.

It would be awesome if someone built a javascript tool that properly escaped the chracters just for picky ol' salesforce.
Hi all,
I have a problem I've not seen until recently.
When I hit save, and throw my own exception: I'm getting a message added to the page: 'Script Thrown Exception'.
This is not a message in the exception that I have made. In addition: it's also adding the desired message from my controller.

Here is what it looks like:
User-added image


The controller code for the save function is as follows:
//SAVE
public void Save(){
    savepoint sp = Database.setSavePoint();
    try {        
        for(AutoNumber__c r : AutoNumberRecords){
            if(r.Length__c == null || r.Length__c < 1){
                CODException e = new CODException(new MessageCodes.MessageCode('AN900','The Length must be greater than 0'));
                r.Length__c.addError(e);
                throw e;
            }
            if(r.CurrentNumber__c == null || r.CurrentNumber__c < 1){
                CODException e = new CODException(new MessageCodes.MessageCode('AN901','The Length must be greater than 0'));
                r.CurrentNumber__c.addError(e);
                throw e;
            }
        }
        Update AutoNumberRecords;
        NextRecordNames = null;
    } catch (exception e){
        ApexPages.addMessages(e);
        Database.rollback(sp);
    }
}


COD Exception is a custom exception class I've made:
public class CODException extends Exception{

//MESSAGE CODE
private MessageCodes.MessageCode MessageCode{get;set;}

// ADDITIONAL_MESSAGES
//The additional messages stores a list of any information to be appended to an error
//    These could be from DML Exceptions, or multiple errors
private list<string> AdditionalMessages{
    get;
    private set;
}

//COD CODE
//Returns the COD error code
public string GetCode(){
    return  MessageCode != null && MessageCode.Code != null ? MessageCode.Code.toUpperCase() : null;         
}    
    
//COD MESSAGE
//Componse a message from what data we have
private string GetCODMessage(){
    string s = (MessageCode != null && MessageCode.Code != null ? MessageCode.Code : '') + (MessageCode != null && MessageCode.Message != null ? ' - ' + MessageCode.Message: '');
    
    if(AdditionalMessages != null && AdditionalMessages.size() > 0) {   
        for(string am : AdditionalMessages){
            s += '<br/>&bull; ' + am;
        }
    }
    return s;
}

//GET MESSAGE
//The overriden GetMessage method from the standard Exception class
//This is designed to show all the additional information that our exception
//    method has in it. It may be augemented over time
//I am unaware of how the 'escaping' will work when throwing this, or when using a
//    standard sObejct.AddError() method with the escape signature passed in   
public override string GetMessage(){
    return GetCODMessage();
}

//CONSTRUCTORS
//With a MessageCodes.MessageCode and a list of string
public CODException(MessageCodes.MessageCode pMessageCode, string[] pAdditionalMessages) {
    MessageCode = pMessageCode;
    AdditionalMessages = pAdditionalMessages;
}
//With a MessageCodes.MessageCode and a set of string
public CODException(MessageCodes.MessageCode pMessageCode, set<string> pAdditionalMessages) {
    this(pMessageCode, new list<string>(pAdditionalMessages));
}
//With a MessageCodes.MessageCode and a string
public CODException(MessageCodes.MessageCode pMessageCode, string pString) {
    this(pMessageCode,new string[]{pString});
}
//With a MessageCodes.MessageCode
public CODException(MessageCodes.MessageCode pMessageCode) {
    MessageCode = pMessageCode;
}
//With a MessageCodes.Message code and a DML Exception
public CODException(Messagecodes.MessageCode pMessageCode, DMLException pDMLx){
    MessageCode = pMessageCode;
    set<string> s = new set<string>();
    for(integer i = 0; i < pDMLx.getNumDML(); i++){
        s.add(pDMLx.getDmlMessage(i));
    }
    AdditionalMessages = new list<string>(s);
}

}

As well as MessageCodes
public class MessageCodes{
////////// ERROR_AND_MESSAGE_CODES //////////
//A class used to hold all Message codes related to a particular area of the system
//    Populated by a map of code to message, and retrieved as a case insensitive map.Get() type
//    of method. 
//This used to be a listing of enum error codes, but it was discovered that enums will only permit 100 entries
//    so I deprecated that to this

//The class that hold all message codes related to a particular area of the system
public MessageCodes.MessageCode Get(string pCode) {
    MessageCode m;
    if(pCode != null && pCode.DeleteWhiteSpace() != '' && MessageCodeMap.get(pCode.ToUpperCase().trim()) != null) {
        m = new MessageCodes.MessageCode(pCode.ToUpperCase().trim(),MessageCodeMap.get(pCode.ToUpperCase().trim()));
    }
    return m;
}

private map<string,string> MessageCodeMap {
    get {
        if(MessageCodeMap == null) {
            MessageCodeMap = new map<string,string>();
        }
        return MessageCodeMap;
    } private set;
}

//CONSTRUCTOR
//Pass in a map of error code to code message
public MessageCodes(map<string,string> pCodeMessages){
    for(string s : pCodeMessages.KeySet()){
        MessageCodeMap.put(s.ToUpperCase().Trim(),pCodeMessages.get(s));
    }
}

//What is returned after requesting an error message and code
public class MessageCode{
    public string Code {get;private set;}
    public string Message {get;private set;}
    
    public MessageCode(string pCode, string pMessage){
        Code = pCode.ToUpperCase().trim();
        Message = pMessage;
    }
}
}


On top of all that, according to the documentation: if I use the sObject.AddError method it is supposed to prevent any DML from ocurring. (As referenced here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm#apex_System_SObject_addError) - however it did not.
If I changed the value in one of my fields to forcibly throw the exception: the DML still occurred. So I had to add the Savepoint and rollback to it... Is this right?

Thanks
  • October 30, 2015
  • Like
  • 0
Hi all,

With the new release of the new developer console: they've broken something else. It appears that running tests from the developer console does not record any rest results.

The only way to get updated code coverage is by running tests from the Apex Test Execution page - which I'm sure will be taken away soon... Anyone know of any work around?

Here is the proof:
http://screencast.com/t/BB3TGw0cSK

In the video I do the following:
1) Run the test class from the developer console.
2) Examine the Overall Code Coverage section to show there is no coverage on the tested class
3) Examine the intended tested class from the developer console to see there is no coverage
4) Navigate to the apex test execution page, and run the same test
5) Navigate back to the developer console to show the test now displays correct coverage

I'm in a developer org, so I can't make a case (we're not worthy of support) so if anyone else cares to: please use my post, and video as evidence
  • October 20, 2015
  • Like
  • 0
Hi all,
I'm implementing KnowledgeArticles  - and I keep running in to issues with this architecture...

I cna't seem to get knowledge article versions sorted by the CaseAssosciationCount...

Here is the query I am  trying to run:
SELECT id FROM KnowledgeArticleVersion WHERE Language = 'en_US' AND PublishStatus = 'Online' AND ValidationStatus = 'Validated' ORDER BY KnowledgeArticle.CaseAssociationCount DESC


And I get my lovely error:
ERROR at Row:1:Column:138
Didn't understand relationship 'KnowledgeArticle' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

What the hell SF? You're tellin me I can't query parent values? how am I supposed to enforce my where clause ?!
  • August 05, 2015
  • Like
  • 0
Hi all,

I'm building a community site with knowledge articles, Questions, and Cases. I can see that questions have a comment/reply system for them (which makes sense) because they are a glorified forum: but I can't find any way to enable this for knowledge base articles. 

I've done a bunch of searching , and every answer I ahve found says they don't: but the posts I've found are also at minimum: two years old...
So can someone clarify if the functionality exists?

Thanks
  • August 05, 2015
  • Like
  • 1
Hi all, this isn't the first time this has happened, but it's finally pissed me off enough to attempt to ask around about it...

I have been building a page with a controller in the DeveloperMode interface for the past week without incident. Now all of a sudden: I am getting this error: "Error: Required fields are missing: Label" when I hit the save button... It's happened to be before on small contracts, and I've had to stop using the interface...
Cryptic SF Error of +1 Annoyance

Has anyone run in to this? How do I avoid it, and or fix it?
Ok, so they've rewroked the interface for their developer guides (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/)  - now when I just want to search for something, I'm confined to this tiny little search result box... And on top of that: the search doesn't even work!

I type in "sObject class" and it's nowhere to be found... In the previous version it would be among the top hits, and I could easily click on it. 

Is there a way to get the old one back? 
I'm writing a managed package, and I'm using a number of fields that are controlled by the system and written to from apex.

Of course, I can restrict access to the fields via a profile, but I don't know how this works with System Administrators in the client's org.

My question is: If I mark a field in my Managed Package as readonly to a system administrator profile, and subsequently deploy that profile when installing the package in a Client's org: Will the system administrator be able to write to that field?

Additionally: Will the client org be able to write their own apex to write to that field?

How do you guys deal with this?

ps: also posted on Stackexchange: http://salesforce.stackexchange.com/questions/33062
  • April 17, 2014
  • Like
  • 0
Hey guys,

I was under the impression that the developer console was going to be hooked in to the streaming API so it wouldn't gorge itself on my API calls and burn through them all by midday...

I couldn't see this listed in the docs - does anyone know if this is happening?
  • March 03, 2014
  • Like
  • 0
Hi guys,

I'm developing an app as a managed package. And I'm running in to two issues:
- How can I supply my customers with additional unmanaged elements to install on top of the package?
- How can I build a plug-in style managed package to work along side my core managed package?

For the first question: I'd like to include some additional parts of it as unmanaged. Things like:
- Pre-built reports
- Custom report types
- Email templates
- Customizable buttons

I have my primary managed app: JayNicsApp - Core.
Then I created two supplementary unmanaged apps: JayNicsApp - Reporting, JayNicsApp - Templates.

But when I created them, it went ahead and added all the dependancies from the managed app to the unmanaged package...
My desired outcome would be a package with just the elements that I want unmanaged and delivered to the customer. If the customer does not have the managed package installed underneath - it should fail to install. I don't want to have to add all of my code and customizations 
to an unmanaged package just for some silly reports...

For the second question:
I'd like to build another piece of managed code that can sit on top of my original core managed package. This would be something like some integrations between my custom objects and CRM objects (Opportunity, Case etc..). This integration would not come standard in the manged package core and would only be needed by customers if they had CRM and not just a Platform license.
How can I go about building that?


Really appreciate the help.
Thanks
-JayNic
 
  • January 24, 2014
  • Like
  • 0
Hi all,

I'm having issues with mass editing from list views while using the static variable trick to control recursive triggers. I dislike this new message format so I've switched over to stackexchange. Please have a look at my full detailed question witch flow and code snippets:

http://salesforce.stackexchange.com/questions/24307 (http://salesforce.stackexchange.com/questions/24307/how-do-i-control-recursive-triggers-with-static-variables-and-permit-mass-edit-f)
  • January 16, 2014
  • Like
  • 1

Hey guys,

 

I have a class that allows users to submit json objects and parses them in to sObjects. It's simpel for strings, and numbers because apex handles those when being assigned to objects. 

 

I'm having trouble finding a good way to handle dates/datetimes.

 

 

 

if(records.size() > 0) {
                        sObjectType s = Schema.getGlobalDescribe().get(sObjectType);
                        list<sObject> objects = new list<sObject>();
                        for(object o : records) {
                            //instantiate a new sObject based on the type specified in the objectMap
                            sObject newRecord = s.newSObject();
                            
                            //Now cast the field mapping definition that the user has passed in to create the record
                            map<string,object> recordDefinition = (map<string,Object>)o;
                            for (string field : recordDefinition.keySet()) {
                                
                                newRecord.put(
                                    field,
                                    recordDefinition.get(field)
                                );
                            }
                            
                            system.debug('UDBG::::insertRecords looped through record and created newRecord: ' + newRecord);
                            objects.add(newRecord);
                        }
                        if(!objects.isEmpty()){
                            insert objects;
                        }
                        responseMessage = objects.size() + ' records inserted';
                        
                    } 

 

Above is my current snippet. Notice that it's all dynamic - the class will allow the user to specify the sObject type - so I figure that out.

 

The "records" variable in the first for loop is an array submitted from json - eg:

[
    {"Name" : "myNewRecordName0", "Type__c" : "MyType0"},
    {"Name" : "myNewRecordName1", "Type__c" : "MyType1"}
]

 I feel like there might be some magic method that can help me out with the next bit... Currently I manually create a new sObject record based on the dynamic type:

 

sObject newRecord = s.newSObject();

Then I just convert each json record to a map, and do a "put" for each field and value with:

                            map<string,object> recordDefinition = (map<string,Object>)o;
                            for (string field : recordDefinition.keySet()) {
                                
                                newRecord.put(
                                    field,
                                    recordDefinition.get(field)
                                );
                            }

 

 

This all works fine until I hit a date, or date time... I have to submit those as strings - eg:

[
    {"Name" : "myNewRecordName0", "Type__c" : "MyType0", "Date__c" : "23-12-2013"},
    {"Name" : "myNewRecordName1", "Type__c" : "MyType1", "Date__c" : "23-12-2013"}
]

 At which point I get the error: 

Illegal assignment from String to Date

 

 

 

SO. Long story short - is there a way I can simply cast my "record" object inteligently to my sObject type? Something like: 

for(object o : records) {
    //instantiate a new sObject based on the type specified in the objectMap
    sObject newRecord = s.newSObject();
    JSON.castSObject(newRecord, o);
}

 

That way I can avoid having to do field type checks on each field and having to cast those individually to the proper field types like "date.valueof("10-10-2013")"

 

 

  • December 05, 2013
  • Like
  • 0

I have built a managed package, and created the namespace and all that....

 

If I use the IDE to pull out all components of the org, and re-deploy them to a new org - will it carry over the name-space, or will I be able to create a new one?

 

Basically, I'm trying to copy my whole org but without the namespace...

  • November 14, 2013
  • Like
  • 0

Hi All,

 

Salesforce has done it again. Not only are they removing functionality we've all grown atteched to by forcing us to use the developer console to show all our test coverage: now it seems that when we use the Developer Console - we chew up all our API calls in our org.

 

I am now incapable of performing any more development for 24hours because the dev console - the Salesforce supported tool PROVIDED to be BY salesforce) - has burned up all of my API calls.

 

This is completely unnacceptable, and is costing my company man hours.

 

Salesforce: you're a billion dollar company and whatever retarded monkey was hired to changed the Developer console should be shot out of a cannon.

  • November 13, 2013
  • Like
  • 0

Hey all,

 

I'm hoping to learn a great deal by posting here to find some expert feedback, and ideas. 

 

It's always been in the back of my mind that the more complex an application gets: the more "setup" based data is required to be populated during test classes. It seems to me that no matter how efficiently I code, follow best practices, and come up with interesting solutions: that I will eventually hit a wall  when it comes to getting (what salesforce deems) the necessary code coverage.

 

My team and I have been building an application for Supply Chain Management. It's a complex beast with many objects, and a great deal of automation and apex driven business logic. The two main application flows facilitate: Purchasing and Selling of Items.

 

This means we have complex systems surrounding pricebooks for Vendors, and Customers, warehouse/location validation, Item Databases, Bill of Materials Management, SalesOrder/Purchase Order management, Inventory Ins/Outs. There are a great deal of things that have to happen for a user to get to the final stage of one of the two main application flows. None of this is meant to happen all at once. It happens over time through a number of different user interfaces - this is basic application design for complex systems 101.

 

My issue comes when covering my code. In order to cover classes that take place at the end of one of the two previously mentioned flows: I have to essentially set up the entire organization. This includes huge numbers of DML statements/queries that have to occur in a single transaction because tests require this!

 

My question to you all is this: What secrets/tips do you have for developing complex applications and avoiding governor limits inside test classes? How do you avoid or mitigate the unnecessary overhead of re-factoring your architecture just for the needs of silly test classes that are ignored by clients during installation anyways?

 

Before you consider referring me to articles about "how to make your triggers batchable" and so on - know that I already do. There is not a single method or function in my entire application (that uses DML/Queries) that is not batchable. I use maps/sets everywhere to a point of obsession.

 

I look forward to what you all have to offer

  • October 25, 2013
  • Like
  • 0

Hi,

 

I'm having trouble coming to terms with the fact that according to the documentation: customers can disable data validation rules in a managed package.

 

http://na15.salesforce.com/help/doc/en/packaging_component_attributes.htm

 

If I'm reading this right, the validation rule can literally be turned off. This effectively "invalidates" data by permitting users to skirt rules they find annoying... As a developer of an app, I need to ensure it functions correctly with the right source data - how can I do this if the very method of validating my data is avoidable?

 

Honestly, I just can't believe this could happen, and I'm hoping I'm mis-interpreting it...

 

So, if this is the case, how am I supposed to validate my applications data?

  • October 07, 2013
  • Like
  • 1

Hi guys,

 

Urgent issue here - I'm trying to build my test classes for a client app to deploy and I cannot see my code coverage. Yes, I know the coverage column has been removed from the setup page list, and I know that I have to open the Developer Console - run a test, then double click the test Run, then double slick the class to see the percentage.

 

When I open the class, and in the top left select the coverage from the drop down - it does not show line by line red/blue coverage despite saying that it has 57% coverage so far.

 

I ahve done this 7 times in chrome and firefox. No dice.

 

I am on CS17. EDIT: CS7

  • September 30, 2013
  • Like
  • 0

Hey all,

 

I'm trying to figure out the simplest way to create an end point in salesforce that consumes a json object.

 

Ideally without requiring force.com authentication, and for calling from a third party application.

 

Is there a way to create a visualforce page, host it on a force.com site, and use currentPage.getParameters() method to grab json post data?

Hi Guys,

 

I'm trying to use an action function to submit parameters to an instantiated sObject.

 

My action function looks like so:

    <apex:actionFunction action="{!updateCredential}" name="af_updateCredential" reRender="none" >
        <apex:param assignTo="{!credential.LastClicked__c}" name="LastClicked__c" value=""/>

    </apex:actionFunction>

<script>

function setClicked(){
    
    var d = new Date();
    var year = d.getFullYear();
    var month = d.getMonth();
    var day = d.getDate();
    var hour = d.getHours();
    var minute = d.getMinutes();
    
    if(month.toString().length == 1) {
        month = '0' + month;
    }
    if(day.toString().length == 1) {
        day = '0' + day;
    }
    if(hour.toString().length == 1) {
        hour = '0' + hour;
    }
    if(minute.toString().length == 1) {
        minute = '0' + minute;
    }
    
    var dt = year + '-' + month + '-' + day + 'T' + hour + ':' + minute +  ':00Z';
    //dt = 'Thu Nov 15 22:29:00 GMT 2012';
    af_updateCredential(dt);
}

</script>

 Where Credential is an sObject with a DateTime field called LastClicked__c.

As you can see, I attempted to format the date/time string to what Apex likes, but I still end up getting an error like so:

--------------------------

Visualforce Error
 

Value '2013-05-19T13:32:00Z' cannot be converted from Text to DateTime

Error is in expression '{!credential.LastClicked__c}' in page credentialsbrowser
--------------------------
 
I really really really don't want to have to write an apex date/time parser JUST for this one silly field, I feel like I should be able to submit it to text with the right formatting.
 
Any help?

Hi,

 

I am attempting to use standard getters and setters in apex for some re-usable methods, but I'm having a little concern over whether or not I am doing it correctly... Please see the following code

public with sharing class shipment_ext{
/*
Logic extenders for the shipment object 
*/
    ////////////// GET_LINE_ITEMS //////////////   
    //Get a map of Shipemnt Id to a list of its child Outbound Line Items by passing in Shipment Ids
    map<id,list<ShipmentLineItemOutbound__c>> outboundLineItems;
    //Generic setter
    public void setOutboundLineItems(map<id,list<ShipmentLineItemOutbound__c>> pMap) {
        this.outboundLineItems = pMap;
    }
    //Get a map of Shipments to outbound line items by passing in a set of shipment ids
    public map<id,list<ShipmentLineItemOutbound__c>> getOutboundLineItems(set<id> pIds) {
        if(this.outboundLineItems == null) {
            map<id,list<ShipmentLineItemOutbound__c>> shpos = new map<id,list<ShipmentLineItemOutbound__c>>();
            if(!pIds.isEmpty()) {
                for(ShipmentLineItemOutbound__c shpo : [SELECT id, Shipment__c FROM ShipmentLineItemOutbound__c WHERE Shipment__c IN :pIds]) {
                    if(shpos.get(shpo.Shipment__c) == null) {
                        shpos.put(shpo.Shipment__c , new list<ShipmentLineItemOutbound__c>());
                    }
                    shpos.get(shpo.Shipment__c).add(shpo);
                }
            }
            this.setOutboundLineItems(shpos);
        }
        return this.outboundLineItems;
    }
}

 

 

Is this best practice?

There is a line in the Apex Dev guide that says:

  • We recommend that your get accessor should not change the state of the object that it is defined on.

I don't know what that means... 

But if I am doing it, how would I get around it?

 

the idea is that I will eventually overload the method eg:

public map<id,list<ShipmentLineItemOutbound__c>> getOutboundLineItems() {
    set<id> ids = new set<id>();
    for(Shipment__c s : [SELECT id FROM Shipment__c LIMIT 10000]){
        ids.add(s.id);
    }
    return getOutboundLineItems(ids);

}

 

Is there a best practice way for me to write this that I am not following?

 

Thanks

Hi all,

I'm building a community site with knowledge articles, Questions, and Cases. I can see that questions have a comment/reply system for them (which makes sense) because they are a glorified forum: but I can't find any way to enable this for knowledge base articles. 

I've done a bunch of searching , and every answer I ahve found says they don't: but the posts I've found are also at minimum: two years old...
So can someone clarify if the functionality exists?

Thanks
  • August 05, 2015
  • Like
  • 1
Hi all,

I'm having issues with mass editing from list views while using the static variable trick to control recursive triggers. I dislike this new message format so I've switched over to stackexchange. Please have a look at my full detailed question witch flow and code snippets:

http://salesforce.stackexchange.com/questions/24307 (http://salesforce.stackexchange.com/questions/24307/how-do-i-control-recursive-triggers-with-static-variables-and-permit-mass-edit-f)
  • January 16, 2014
  • Like
  • 1

Hi,

 

I'm having trouble coming to terms with the fact that according to the documentation: customers can disable data validation rules in a managed package.

 

http://na15.salesforce.com/help/doc/en/packaging_component_attributes.htm

 

If I'm reading this right, the validation rule can literally be turned off. This effectively "invalidates" data by permitting users to skirt rules they find annoying... As a developer of an app, I need to ensure it functions correctly with the right source data - how can I do this if the very method of validating my data is avoidable?

 

Honestly, I just can't believe this could happen, and I'm hoping I'm mis-interpreting it...

 

So, if this is the case, how am I supposed to validate my applications data?

  • October 07, 2013
  • Like
  • 1
Not sure, what is wrong with following code. While validating, it give me following error:
The campingList component isn't handing the added item correctly.

Here is the code:
1. camping.cmp
<aura:component >
    <c:campingHeader />
    <c:campingList />
</aura:component>
2. CampingList.cmp
<aura:component controller="CampingListController">
    
    <aura:attribute name="items" type="Camping_Item__c[]"/>
    
    <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
    <aura:handler name="addItem" action="{!c.handleAddItem}" event="c:addItemEvent"/>
    
    <c:campingListForm />
    
    <div class="slds-card slds-p-top--medium">
        <header class="slds-card__header">
            <h3 class="slds-text-heading--small">Expenses</h3>
        </header>
        
        <section class="slds-card__body">
            <div id="list" class="row">
                <aura:iteration items="{!v.items}" var="item">
                    <c:campingListItem item="{!item}"/>
                    <br/>
                </aura:iteration>
            </div>
        </section>
    </div>
    
</aura:component>

3. campingListController.js
({
    // Load expenses from Salesforce
    doInit: function(component, event, helper) {
        
        // Create the action
        var action = component.get("c.getItems");
        
        // Add callback behavior for when response is received
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                component.set("v.items", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        
        // Send action off to be executed
        $A.enqueueAction(action);
    },
    
    handleAddItem : function(component, event, helper) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": JSON.parse(JSON.stringify(event.getParam("item")))
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var items = component.get("v.items");
                items.push(response.getReturnValue());
                component.set("v.items", items);
            }
        });
        $A.enqueueAction(action);
    }
})

4. componentListHelper.js
({
    createCamping: function(component,item) {
        
        var action = component.get("c.saveItem");
        action.setParams({
            "item": JSON.parse(JSON.stringify(item))
        });
        action.setCallback(this, function(response){
            var state = response.getState();
            if (component.isValid() && state === "SUCCESS") {
                var items = component.get("v.items");
                items.push(response.getReturnValue());
                component.set("v.items", items);
            }
        });
        $A.enqueueAction(action);
    }
})
5. campingListForm.cmp
<aura:component >
    
    <aura:attribute name="newItem" type="Camping_Item__c"
                    default="{ 'sobjectType': 'Camping_Item__c',
                             'Name': '',
                             'Packed__c': false,
                             'Price__c': '0',
                             'Quantity__c': '0' }"/>
    
    <aura:registerEvent name="addItem" type="c:addItemEvent"/>
    
    <div aria-labelledby="newitemform">
        <fieldset class="slds-box slds-theme--default slds-container--small">
            
            <legend id="newitemform" class="slds-text-heading--small 
                                            slds-p-vertical--medium">
                Add Camping Item
            </legend>
            
            <form class="slds-form--stacked">
                
                <div class="slds-form-element slds-is-required">
                    <div class="slds-form-element__control">
                        <ui:inputText aura:id="name" label="Camping Item Name"
                                      class="slds-input"
                                      labelClass="slds-form-element__label"
                                      value="{!v.newItem.Name}"
                                      required="true"/>
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <ui:inputCheckbox aura:id="packed" label="Packed?"
                                      class="slds-checkbox"
                                      labelClass="slds-form-element__label"
                                      value="{!v.newItem.Packed__c}"/>
                </div>
                
                <div class="slds-form-element">
                    <div class="slds-form-element__control">
                        <ui:inputCurrency aura:id="price" label="Price"
                                          class="slds-input"
                                          labelClass="slds-form-element__label"
                                          value="{!v.newItem.Price__c}" />
                        
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <div class="slds-form-element__control">
                        <ui:inputNumber aura:id="quantity" label="Quantity"
                                        class="slds-input"
                                        labelClass="slds-form-element__label"
                                        value="{!v.newItem.Quantity__c}"/>
                        
                    </div>
                </div>
                
                <div class="slds-form-element">
                    <ui:button label="Create Camping Item"
                               class="slds-button slds-button--brand"
                               press="{!c.submitForm}"/>
                </div>
                
            </form>
            
        </fieldset>
    </div>
    
</aura:component>
6. campingListFormController
({    
    
    submitForm : function(component, event, helper) {
        
        var validCamping = true;

        // Name must not be blank
        var nameField = component.find("name");
        var expname = nameField.get("v.value");
        if ($A.util.isEmpty(expname)){
            validCamping = false;
            nameField.set("v.errors", [{message:"Camping Item name can't be blank."}]);
        }
        else {
            nameField.set("v.errors", null);
        }

        
        var priceField = component.find("price");
        var price = priceField.get("v.value");
        if ($A.util.isEmpty(price) || isNaN(price) || (price <= 0.0)){
            validCamping = false;
            priceField.set("v.errors", [{message:"Camping Item price can't be blank."}]);
        }
        else {
            priceField.set("v.errors", null);
        }
        
        var quantityField = component.find("quantity");
        var quantity = quantityField.get("v.value");
        if ($A.util.isEmpty(quantity) || isNaN(quantity) || (quantity <= 0)){
            validCamping = false;
            quantityField.set("v.errors", [{message:"Camping Item quantity can't be blank."}]);
        }
        else {
            quantityField.set("v.errors", null);
        }

        if(validCamping){
            
            helper.createItem(component);
        }
    },
})

7. campingListFormHelper.js
({
    
     createItem : function(component) {
        var newItem = component.get("v.newItem");
        var addEvent = component.getEvent("addItem");
        addEvent.setParams({"item" : newItem});
        addEvent.fire();
        component.set("v.newItem",
                     { 'sobjectType': 'Camping_Item__c',
                    'Name': '',
                    'Packed__c': false,
                    'Price__c': 0,
                    'Quantity__c': 0});
    }
})

8. addItemEvent.evt
<aura:event type="COMPONENT" description="Event template">
    <aura:attribute name="item" type="Camping_Item__c"/>
</aura:event>

It works well, when I test this app. any thought? Can anyone share the working code for this module?


 
Hey guys,
I'm trying to implement a regex, and I can't figure out what the hell I'm doing wrong and what to escape... I keep getting 'invalid characters sequence' in whatever I try.

Here is the regex: ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?

It will return me groups of the url parsed. I'm supposed to do something like the following:
Pattern myPattern = Pattern.Compile('^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?');
matcher myMatcher = myPattern.matcher(pUrl);
myMatcher.matches();

for(integer i = 0; i < myMatcher.groupCount();i++){
    system.debug(
	    myMatcher.group(i)
    );
}

I've tried backslash escaping the backslashes, double escaping, using Pattern.Quote(), murdering coworkers.... Nothing works.

It would be awesome if someone built a javascript tool that properly escaped the chracters just for picky ol' salesforce.
Hi all,

With the new release of the new developer console: they've broken something else. It appears that running tests from the developer console does not record any rest results.

The only way to get updated code coverage is by running tests from the Apex Test Execution page - which I'm sure will be taken away soon... Anyone know of any work around?

Here is the proof:
http://screencast.com/t/BB3TGw0cSK

In the video I do the following:
1) Run the test class from the developer console.
2) Examine the Overall Code Coverage section to show there is no coverage on the tested class
3) Examine the intended tested class from the developer console to see there is no coverage
4) Navigate to the apex test execution page, and run the same test
5) Navigate back to the developer console to show the test now displays correct coverage

I'm in a developer org, so I can't make a case (we're not worthy of support) so if anyone else cares to: please use my post, and video as evidence
  • October 20, 2015
  • Like
  • 0
Hi!

I am setting up a class, called via a trigger, to set an email address. I need to go from my custom object Product_Assessment__c to its parent case and then on to the contact, retrieve the email and populate it. I have the class working but it is not bulkified, my loop as 2 SOQL query's in it and  as we all know that's just BAD! I know I need to build up a map to return the correct  email address but am struggling a bit. can someone lend a hand? 
​Thanks for your time!


 
public with sharing class Product_Assessment_set_contact_email {
	
	// These variables store Trigger.oldMap and Trigger.newMap
  Map<Id, Product_Assessment__c> oldpas;
  Map<Id, Product_Assessment__c> newpas;	
	
// This is the constructor
// A map of the old and new records is expected as inputs
  public Product_Assessment_set_contact_email(
    Map<Id, Product_Assessment__c> oldTriggerpas, 
    Map<Id, Product_Assessment__c> newTriggerpas) {
      oldpas = oldTriggerpas;
      newpas = newTriggerpas;
  }
  
  
  public void set_email(){
  

  	for (Product_Assessment__c p : newpas.values())      
       {
       	
       	case con = [SELECT ContactId FROM Case WHERE Id = :p.case__c ];
       	
       	contact em = [select email from contact where id = :con.ContactId];
       	
       	p.email_of_contact__c = em.email;

       }
  }
  

}

 
Hi all,
I'm implementing KnowledgeArticles  - and I keep running in to issues with this architecture...

I cna't seem to get knowledge article versions sorted by the CaseAssosciationCount...

Here is the query I am  trying to run:
SELECT id FROM KnowledgeArticleVersion WHERE Language = 'en_US' AND PublishStatus = 'Online' AND ValidationStatus = 'Validated' ORDER BY KnowledgeArticle.CaseAssociationCount DESC


And I get my lovely error:
ERROR at Row:1:Column:138
Didn't understand relationship 'KnowledgeArticle' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

What the hell SF? You're tellin me I can't query parent values? how am I supposed to enforce my where clause ?!
  • August 05, 2015
  • Like
  • 0
Hi all,

I'm building a community site with knowledge articles, Questions, and Cases. I can see that questions have a comment/reply system for them (which makes sense) because they are a glorified forum: but I can't find any way to enable this for knowledge base articles. 

I've done a bunch of searching , and every answer I ahve found says they don't: but the posts I've found are also at minimum: two years old...
So can someone clarify if the functionality exists?

Thanks
  • August 05, 2015
  • Like
  • 1
Hi all, this isn't the first time this has happened, but it's finally pissed me off enough to attempt to ask around about it...

I have been building a page with a controller in the DeveloperMode interface for the past week without incident. Now all of a sudden: I am getting this error: "Error: Required fields are missing: Label" when I hit the save button... It's happened to be before on small contracts, and I've had to stop using the interface...
Cryptic SF Error of +1 Annoyance

Has anyone run in to this? How do I avoid it, and or fix it?
I have tried this code for custom button for single click email sending. Unfortunately It is not working and showing error. Could anyone tell me where I am doing wrong and correct me please.

Thank you.
location.replace('/email/author/emailauthor.jsp retURL=/{!Opportunity.Id}&p24="varunreddypenna@gmail.com,v.reddy@thegordiangroup.com"&template_id="00Xj0000000J8sI"&p3_lkid={!Opportunity.Id}&p3={!Opportunity.Name}&p26={!User.Email}&p5="penna.janareddy@gmail.com"&save=0')
User-added image
User-added image

 
Ok, so they've rewroked the interface for their developer guides (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/)  - now when I just want to search for something, I'm confined to this tiny little search result box... And on top of that: the search doesn't even work!

I type in "sObject class" and it's nowhere to be found... In the previous version it would be among the top hits, and I could easily click on it. 

Is there a way to get the old one back? 
Hi guys,

I'm developing an app as a managed package. And I'm running in to two issues:
- How can I supply my customers with additional unmanaged elements to install on top of the package?
- How can I build a plug-in style managed package to work along side my core managed package?

For the first question: I'd like to include some additional parts of it as unmanaged. Things like:
- Pre-built reports
- Custom report types
- Email templates
- Customizable buttons

I have my primary managed app: JayNicsApp - Core.
Then I created two supplementary unmanaged apps: JayNicsApp - Reporting, JayNicsApp - Templates.

But when I created them, it went ahead and added all the dependancies from the managed app to the unmanaged package...
My desired outcome would be a package with just the elements that I want unmanaged and delivered to the customer. If the customer does not have the managed package installed underneath - it should fail to install. I don't want to have to add all of my code and customizations 
to an unmanaged package just for some silly reports...

For the second question:
I'd like to build another piece of managed code that can sit on top of my original core managed package. This would be something like some integrations between my custom objects and CRM objects (Opportunity, Case etc..). This integration would not come standard in the manged package core and would only be needed by customers if they had CRM and not just a Platform license.
How can I go about building that?


Really appreciate the help.
Thanks
-JayNic
 
  • January 24, 2014
  • Like
  • 0

I have built a managed package, and created the namespace and all that....

 

If I use the IDE to pull out all components of the org, and re-deploy them to a new org - will it carry over the name-space, or will I be able to create a new one?

 

Basically, I'm trying to copy my whole org but without the namespace...

  • November 14, 2013
  • Like
  • 0

Hi All,

 

Salesforce has done it again. Not only are they removing functionality we've all grown atteched to by forcing us to use the developer console to show all our test coverage: now it seems that when we use the Developer Console - we chew up all our API calls in our org.

 

I am now incapable of performing any more development for 24hours because the dev console - the Salesforce supported tool PROVIDED to be BY salesforce) - has burned up all of my API calls.

 

This is completely unnacceptable, and is costing my company man hours.

 

Salesforce: you're a billion dollar company and whatever retarded monkey was hired to changed the Developer console should be shot out of a cannon.

  • November 13, 2013
  • Like
  • 0

Hello,

 

We are looking to create an exact clone of our production Salesforce instance into a new, completely separate enterprise instance of Salesforce. I would like everything to clone over such as custom objects, fields, triggers, workflows, apex classes, visualforce pages, etc. Has anyone been through a similar situation? I'm looking for all and any advice on the easiest way to complete this task.

 

Thank you in advance!!

  • November 08, 2013
  • Like
  • 0

Hey all,

 

I'm hoping to learn a great deal by posting here to find some expert feedback, and ideas. 

 

It's always been in the back of my mind that the more complex an application gets: the more "setup" based data is required to be populated during test classes. It seems to me that no matter how efficiently I code, follow best practices, and come up with interesting solutions: that I will eventually hit a wall  when it comes to getting (what salesforce deems) the necessary code coverage.

 

My team and I have been building an application for Supply Chain Management. It's a complex beast with many objects, and a great deal of automation and apex driven business logic. The two main application flows facilitate: Purchasing and Selling of Items.

 

This means we have complex systems surrounding pricebooks for Vendors, and Customers, warehouse/location validation, Item Databases, Bill of Materials Management, SalesOrder/Purchase Order management, Inventory Ins/Outs. There are a great deal of things that have to happen for a user to get to the final stage of one of the two main application flows. None of this is meant to happen all at once. It happens over time through a number of different user interfaces - this is basic application design for complex systems 101.

 

My issue comes when covering my code. In order to cover classes that take place at the end of one of the two previously mentioned flows: I have to essentially set up the entire organization. This includes huge numbers of DML statements/queries that have to occur in a single transaction because tests require this!

 

My question to you all is this: What secrets/tips do you have for developing complex applications and avoiding governor limits inside test classes? How do you avoid or mitigate the unnecessary overhead of re-factoring your architecture just for the needs of silly test classes that are ignored by clients during installation anyways?

 

Before you consider referring me to articles about "how to make your triggers batchable" and so on - know that I already do. There is not a single method or function in my entire application (that uses DML/Queries) that is not batchable. I use maps/sets everywhere to a point of obsession.

 

I look forward to what you all have to offer

  • October 25, 2013
  • Like
  • 0
why it give me error on the Action.User ?
how can i know the names of the standard objects ?
  • December 14, 2008
  • Like
  • 1