• DrBix65
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 4
    Replies

I have an odd problem with a utility class.  Assume I have two objects, Object1 and Object2 that have a Master-Detail relationship.  I have two methods that look like this:

 

@RemoteAction

public static List<Object1__c> getList () {

  return [

    Select

      Id,

      Name,

     (Select Id, Name from Object2__r)

    From

      Object1__c

    Where Id = :someId

  ];

}

 

@RemoteAction

public static void saveList (List<Object1__c> objList) {

  // Update the list

}

 

Both methods work perfectly using Javascript remoting.  However, when there are actually CHILD objects in the query, the save fails with (pretty much) no useful information.  Is there some bug, or "gotcha" that I'm not aware of that affects remoting of objects that have a master-detail relationship?

 

Thanks in advance.

I have two remote actions in my class that are simalar to this:

 

@RemoteAction

public static List<Statement__c> getStatements () {

}

 

@RemoteAction

public static void saveStatements (List<Statement__c> statements) {

}

 

and in my Visualforce page, I have Javascript that looks like this:

    StatementFunctions.getStatements (selectedList, function (results, event) {
        arrayOfStatements = results;

    });

 

Later in the Visualforce page, I call:

    StatementFunctions.saveStatements (arrayOfStatements) {

    });

 

This is all working very well with one exception.  The Statement__c object has master detail with another object Line_Item__c so that one Statement__c object can have many Line_Item__c objects.  When the statement object has no line items, it works.  However, when child objects are returned in the list, it fails with an exception (and no message as to why).  Developer console doesn't help either, which makes me think that the data is not being serialized or deserialized in the Javascript correctly.

 

Has anyone seen this behavior before, or does anyone have a solution to how to fix this problem?

 

Thanks in advance.

 

I've been struggling to figure out how to solve this problem.  I have a hierarchical custom setting called "Settings__c."  I'm trying to fetch a field on that setting at the Org level.  The problem lies in the fact that the code does not actually "know" which custom setting or field is being fetched.  The code looks something like this:

 

public Object fetchCustomHierarchySetting (String setting, String field) {

  Schema.SObjectType objType = this.getObjectType (setting);

  if (objType != null) {

    ...

  }

  return null;

}

 

The problem is where the "..." is.  I cannot seem to find any method that lets me fetch the org defaults for the hierarchy setting.  Is there some way to accomplish this?  Since the code doesn't know which custom setting is being instantiated, it can't just typecast to the hierarchy setting; and there doesn't seem to be a "parent object' that provides static initializers.

 

Thanks in advance.

Our company is in the process of trying to create and license our software.  One of the issues that I'm having is providing in such a way that the licensee can customize it.  For example, we have pages that include our company's name on it.  What I'm trying to do is allow the customer to change that particular item.  However, because we're distributing the application as a managed package, the client is unable to modify anything.  I've tried using custom labels, but the same issue occurs.  Once the manage package is deployed in a client's org, the labels become read-only.  The only thing that I've come up with would be a cusom object, and that complicates things considerably.  For example, for a custom label, a Visualforce page would simply use {!$Label.Company_Name} as the reference.  If I use a custom object, then it's not as simple and would actually cause a SOQL query on each page load.

 

My question is:  Is there any "best practice" in a managed package  that allows a client to customize certain aspects of the application?

 

Thanks in advance.

Is there a way, in Apex, to determine which Record Types are assigned for a user?  In otherwords, query the same information that is available in:

[Your Name] -> Setup -> Manage Users -> Profiles -> [Profile] -> Object Settings -> [Object]

 

I've looked everywhere to try and find the schema related to this but have not yet been successful.

 

Thanks in advance.

Hi Everyone, 

 

I have gotten an error on the following trigger saying that I am going over the query limit. I keep reading that it is because I have my "SQL query" within my "FOR" loop.

Can someone please show me how to rework this code so I won't hit my limit?

 

I have seen other examples but can't apply it to my own. If I can see this trigger reworked- i think it will really help me understand. Thanks!

 

All this trigger does is update the name of the "Parent opportunity" when any of the "Related Opportunity" child records are changed.

 

 

trigger countopptyonchildchange on Opportunity (after insert, after update, after undelete)
{
list<Opportunity> ParentOpptys = new list<opportunity>();
list<id> relatedIDs = new list<id>();

for(Opportunity Ropp : trigger.new)
{
if(Ropp.Parent_Opportunity__c != null)
{
relatedIDs.add(Ropp.Parent_Opportunity__c);
}
}

for(Opportunity Popp: [select Id, name from Opportunity where Id in : relatedIDs])
{
Popp.name=popp.name;
ParentOpptys.add(Popp);
}

update ParentOpptys;
}

Our company is in the process of trying to create and license our software.  One of the issues that I'm having is providing in such a way that the licensee can customize it.  For example, we have pages that include our company's name on it.  What I'm trying to do is allow the customer to change that particular item.  However, because we're distributing the application as a managed package, the client is unable to modify anything.  I've tried using custom labels, but the same issue occurs.  Once the manage package is deployed in a client's org, the labels become read-only.  The only thing that I've come up with would be a cusom object, and that complicates things considerably.  For example, for a custom label, a Visualforce page would simply use {!$Label.Company_Name} as the reference.  If I use a custom object, then it's not as simple and would actually cause a SOQL query on each page load.

 

My question is:  Is there any "best practice" in a managed package  that allows a client to customize certain aspects of the application?

 

Thanks in advance.

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