• NickDev
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 11
    Replies
Hi,

We have a managed package. Is it possible to use Salesforce DX to write triggers and classes using objects provided by the managed package?

When creating a scratch org, there is nothing associated with the managed package in there so how can you develop code against objects that are part of the managed package?

Thank you
Hi,

We have a managed package in Production. Is it possible to use Salesforce DX to write triggers and classes using objects provided by the managed package?

When creating a scratch org, there is nothing associated with the managed package in there (which would be normal) so how can you develop associaited code or even fields related to these objects?

Thank you
Hi,

I have a VisualForce page which has a custom controller, I am displaying some data on a PageBlockTable and I have implemented the Comparable interface on a wrapper class and the sorting works fine.

I am now trying to allow you to sort in ascending or descending direction, but to do this I was planning on storing the direction inside a variable on the custom controller inside the top level class.

But the variable is lost each time the user goes to sort, I assume because the viewstate is lost.

I tried storing the variables inside another class and creating an instance of that class but the same thing happens because the instance is probably lost.

What would the correct way of doing this be? I could probably do this in javascript and pass ASC or DESC but I prefer the other method as I also want to extend this to other columns.

Thank you
Hi,

I have a Wrapper Class which has two object type's declared inside it which stored in it.

I'm then adding an instance of this class to a list. The reason I had to do this is because there is a polymorphic field in the ProcessWorkItem object and I needed to loop through all records to get the related information.

The problem is, I cannot get the Comparable Interface working on these objects in order to sort the list accordingly.

The code executes without errors but the list is not sorted.

I've triggering this by using myList.sort();
public Class MyWrapper implements Comparable {
        public ProcessInstanceWorkitem obj1 {get; set;}
        public MySalesforceObject obj2 {get; set;}
        
        public Integer compareTo(Object o)
        {
            MyWrapper comparemyWrp = (MyWrapper)(o);
            
            if (SORT_BY == ACTOR_SORT) {
                return sortByActor(comparemyWrp);
            }
            return 0;
        }
        private Integer sortByActor(MyWrapper wrap) {
            if (this.obj2.CreatedDate > wrap.obj2.CreatedDate) {
                return 1;
            }
            
            if (this.obj2.CreatedDate == wrap.obj2.CreatedDate) {
                return 0;
            }
           
            return -1;
        }
    }

Any help would be great
Hi,

I am writing a Utility Test Class which can be called by many test methods.

Basically, the data I am creating as part of this has a lot of pre-requisit bits of data.

My question is, would you normally call one method inside each other method in the test class to generate each pre-requisit bit of data or would you just simply call every test method seperately from the main test class? - Thank you

Example one:
@isTest(seeAllData=false)
public class TestUtilityClass {

public Account CreateAccount() {
     Account acct = new Account();
     acct.Name = 'Joe Bloggs & Co';
     insert acct;
     return acct;
}

public Contact CreateContact() {
     Account acct = CreateAccount();
     Contact contact = new Contact();
     contact.FirstName = 'Joe';
     contact.LastName = 'Bloggs';
     contact.AccountId = acct.Id;
     insert contact;
     return contact;
}
Then you call call it by
 
TestUtilityClass tcUtil = new TestUtilityClass();

Contact person = tcUtil.CreateContact();


Example two:
@isTest(seeAllData=false)
public class TestUtilityClass {

public Account CreateAccount() {
     Account acct = new Account();
     acct.Name = 'Joe Bloggs & Co';
     insert acct;
     return acct;
}

public Contact CreateContact(Account acct) {
     Contact contact = new Contact();
     contact.FirstName = 'Joe';
     contact.LastName = 'Bloggs';
     contact.AccountId = acct.Id;
     insert contact;
     return contact;
}
Then you call call it by:
TestUtilityClass tcUtil = new TestUtilityClass();

Account acct = tcUtil.CreateAccount();
Contact person = tcUtil.CreateContact(acct);
Hi,

I've written an apex Test class to test my Apex code before deployment.

I have a general test class I created which works to create a specific record of data, but its quite complex due to the amount of other bits of data that need created first due to lookups etc..

So in my new test class I would like to call this first test class to generate some data.

I can see on https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_utility_classes.htm it says to just call it using TestClass.Method() which I have tried but because the class I am calling has Test.startTest(); it complains the test is already running?

Also, I would obviously only like my new test class to carry on once the class I am calling has finished and there is data. Is this possible or am I doing something wrong?

Thank you!
 
Hi,

I am trying to query the ProcessInstanceWorkitem object which has a relationship to the ProcessInstance object, however the ProcessInstance object has a polymorphic relationship by using the TargetObject field.

The question is, with my query below - I understand I can either use seperate querie's to get to those custom fields in whaterver object relates to them or you could use TYPEOF (although that does not seem to be enabled or possible yet).

So I am left with option 1 of having a seperate query, the issue is I don't quite understand how I can do a second query of this related object and get to the custom fields and them combine them into one List so I can display in a PageBlockTable?

Here is my query:
 
results = [Select p.ProcessInstance.Status, p.ProcessInstance.TargetObject.Name, p.Actor.Name, p.CreatedBy.Name, p.CreatedDate FROM ProcessInstanceWorkitem p WHERE (CALENDAR_MONTH(p.CreatedDate) = : dropdownMonth AND CALENDAR_YEAR(p.CreatedDate) = :dropdownYear)];

Any help would be great! Thanks


 
Hi,

I have the following in my controller for a visualforce page which is consumed by a PageBlockDataTable.

I can access other standard fields of the p.ProcessInstance.TargetObject such as p.ProcessInstance.TargetObject.Name and .Id etc...

But how can I access custom fields of TargetObject? Or is this not possible? If its not possible then I assume I can do it in a seperate query, but I cannot figure out how.

Thank you
 
List<ProcessInstanceWorkitem> results = [Select p.ProcessInstance.Status, p.ProcessInstance.TargetObject.Name, p.ProcessInstance.TargetObject.Id, p.Actor.Name, p.CreatedBy.Name, p.CreatedDate FROM ProcessInstanceWorkitem p];

 
I have an object that has mulitple fields such as Week_End_Date, Monday_Hours, Tuesday_Hours, Wednesday_Hours, Thursday_Hours, Friday_Hours

I'm trying to use Apex consumed by a Visual Force page to basically convert this into seperate rows - a bit like a pivot, like this:

Week_End_Date, Monday_Hours
Week_End_Date, Tuesday_Hours
Week_End_Date, Wednesday_Hours
Week_End_Date, Thursday_Hours
Week_End_Date, Friday_Hours

What would the best way to achieve this be?

Thanks
Hi,

When adding metadata to a project, our Managed Package is missing from the src folder and I cannot see any of the objects.

I can see the managed package in 'Referenced Packages' but you cannot modify anything in there.

Is there anyway these can be included in the project as I can modify the objects within the web interface.

Thanks
I am trying to deploy a Trigger and also an Apex class which the trigger is using.

In Sandbox, I wrote a test case which gives the Apex Class 85% coverage and the Trigger says it has 100% code coverage.

I put these both in an outbound change set and push to production.

On production I validate it and then it fails on code coverage and says my trigger has 0% coverage?

Thanks
I've started writing a Test Case so I can deploy my trigger. These are both for custom objects, however these are also on a managed package.

I am getting the following error when executing my test case:
 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, pse.handleTimecardHeaderChange: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

I assume there is a perticular field which is used in an existing Trigger called pse.handleTimecardHeaderChange. However it has not been made mandatory, therefore the field is null?

If I am correct, how can I go about troubleshooting this as when I create the record through the Page it works fine and I cannot see any other fields that are populated by default.

Thanks
Hi,

We have a managed package. Is it possible to use Salesforce DX to write triggers and classes using objects provided by the managed package?

When creating a scratch org, there is nothing associated with the managed package in there so how can you develop code against objects that are part of the managed package?

Thank you
Hi,

We have a managed package in Production. Is it possible to use Salesforce DX to write triggers and classes using objects provided by the managed package?

When creating a scratch org, there is nothing associated with the managed package in there (which would be normal) so how can you develop associaited code or even fields related to these objects?

Thank you
Hi,

I have a Wrapper Class which has two object type's declared inside it which stored in it.

I'm then adding an instance of this class to a list. The reason I had to do this is because there is a polymorphic field in the ProcessWorkItem object and I needed to loop through all records to get the related information.

The problem is, I cannot get the Comparable Interface working on these objects in order to sort the list accordingly.

The code executes without errors but the list is not sorted.

I've triggering this by using myList.sort();
public Class MyWrapper implements Comparable {
        public ProcessInstanceWorkitem obj1 {get; set;}
        public MySalesforceObject obj2 {get; set;}
        
        public Integer compareTo(Object o)
        {
            MyWrapper comparemyWrp = (MyWrapper)(o);
            
            if (SORT_BY == ACTOR_SORT) {
                return sortByActor(comparemyWrp);
            }
            return 0;
        }
        private Integer sortByActor(MyWrapper wrap) {
            if (this.obj2.CreatedDate > wrap.obj2.CreatedDate) {
                return 1;
            }
            
            if (this.obj2.CreatedDate == wrap.obj2.CreatedDate) {
                return 0;
            }
           
            return -1;
        }
    }

Any help would be great
Hi,

I am writing a Utility Test Class which can be called by many test methods.

Basically, the data I am creating as part of this has a lot of pre-requisit bits of data.

My question is, would you normally call one method inside each other method in the test class to generate each pre-requisit bit of data or would you just simply call every test method seperately from the main test class? - Thank you

Example one:
@isTest(seeAllData=false)
public class TestUtilityClass {

public Account CreateAccount() {
     Account acct = new Account();
     acct.Name = 'Joe Bloggs & Co';
     insert acct;
     return acct;
}

public Contact CreateContact() {
     Account acct = CreateAccount();
     Contact contact = new Contact();
     contact.FirstName = 'Joe';
     contact.LastName = 'Bloggs';
     contact.AccountId = acct.Id;
     insert contact;
     return contact;
}
Then you call call it by
 
TestUtilityClass tcUtil = new TestUtilityClass();

Contact person = tcUtil.CreateContact();


Example two:
@isTest(seeAllData=false)
public class TestUtilityClass {

public Account CreateAccount() {
     Account acct = new Account();
     acct.Name = 'Joe Bloggs & Co';
     insert acct;
     return acct;
}

public Contact CreateContact(Account acct) {
     Contact contact = new Contact();
     contact.FirstName = 'Joe';
     contact.LastName = 'Bloggs';
     contact.AccountId = acct.Id;
     insert contact;
     return contact;
}
Then you call call it by:
TestUtilityClass tcUtil = new TestUtilityClass();

Account acct = tcUtil.CreateAccount();
Contact person = tcUtil.CreateContact(acct);
List<new_namespace__Account_Histroy__c> result=[select new_namespace__Account_Id__c,Count(Name) Name ,new_namespace__Account_Owner_New__c,new_namespace__Account_Owner_Old__c,
                                        new_namespace__Name_New__c,new_namespace__Name_Old__c,new_namespace__Account_Number_New__c,new_namespace__Account_Number_Old__c,new_namespace__Account_Website_New__c,
                                        new_namespace__Account_Website_Old__c,FORMAT(new_namespace__Modified_By_New__c) ModifyN,FORMAT(new_namespace__Modified_By_Old__c) ModifyO from new_namespace__Account_Histroy__c
                                        group By FORMAT(new_namespace__Modified_By_Old__c) ModifyO
                                        ];
Hi,

I have the following in my controller for a visualforce page which is consumed by a PageBlockDataTable.

I can access other standard fields of the p.ProcessInstance.TargetObject such as p.ProcessInstance.TargetObject.Name and .Id etc...

But how can I access custom fields of TargetObject? Or is this not possible? If its not possible then I assume I can do it in a seperate query, but I cannot figure out how.

Thank you
 
List<ProcessInstanceWorkitem> results = [Select p.ProcessInstance.Status, p.ProcessInstance.TargetObject.Name, p.ProcessInstance.TargetObject.Id, p.Actor.Name, p.CreatedBy.Name, p.CreatedDate FROM ProcessInstanceWorkitem p];

 
Hi SFDC, I'm new in the Apex world :)
I have some trouble with picklist value, i will explain.
I have a picklist that show me the StartDate from the Period Objects.
I have also a List of ForecastingQuota by User.
The problem is that when I select a value in the picklist, the controller doesn't get it, so my query wich show the user can't change.
Controller :
public List<SelectOption> optionspl {get;set;}
public List<User> resultsusers{get;set;}
public Date dateinput{get;set;}
public Date dateinput2 {get;set;}


public List<SelectOption> getPeriodList(){
 		List<SelectOption> optionspl = new List<SelectOption>();
 		List<SObject> resultspl = [SELECT FullyQualifiedLabel, StartDate FROM Period WHERE StartDate > TODAY AND Type = 'Quarter'];
 		for(SObject pl : resultspl){
 			optionspl.add(new SelectOption(String.valueOf(pl.get('StartDate')),String.valueOf(pl.get('StartDate'))));
 		}
 		return optionspl;
 	}

public  List<ForecastingQuota> getAllQuotas(){
		dateinput = Date.today();
		date mydate2 = mydate.addDays(90);

		List<ForecastingQuota> resultsquotas = new List<ForecastingQuota>();
	    resultsquotas = [SELECT Id,QuotaAmount,QuotaOwnerId, StartDate FROM ForecastingQuota WHERE StartDate >:dateinput AND StartDate <:mydate2 ORDER BY QuotaOwnerId, StartDate ASC];
	    
	    List<User> resultsusers = new List<User>();
		resultsusers = [SELECT Id FROM User WHERE IsActive = TRUE AND ForecastEnabled = TRUE LIMIT 999];

		Map<Id, ForecastingQuota> fqsByOwnerId = new Map<Id, ForecastingQuota>();
			for (ForecastingQuota fq : resultsquotas)
			{
			    fqsByOwnerId.put(fq.QuotaOwnerId, fq);
			}
		
			// new map of quotas keyed by all user ids
		Map<Id, ForecastingQuota> allUserFqsByOwnerId = new Map<Id, ForecastingQuota>();
			for (User u : resultsusers)
			{
			     allUserFqsByOwnerId.put(u.id, fqsByOwnerId.containsKey(u.id) ? fqsByOwnerId.get(u.id) : new ForecastingQuota(QuotaOwnerId = u.id, QuotaAmount = null));
			    	
			}
			List<ForecastingQuota> allthequotas = new List<ForecastingQuota>();
			allthequotas = allUserFqsByOwnerId.values();
			allthequotas.sort();
			return allthequotas;
	}

And the VFP code :
<apex:pageBlockSection columns="4">
<apex:selectList value="{!dateinput2}" id="dateinput2" size="1">
    <apex:selectOptions value="{!periodlist}" />
     <apex:actionSupport event="onchange" rerender="allquotas"/>
</apex:selectList>
			<apex:pageBlockTable value="{!allquotas}" var="key">
				<apex:column>
				<input type="checkbox" name="pouet"/>
				</apex:column>
				<apex:column headerValue="Name">
				    <apex:outputField  value="{!key.QuotaOwnerId}"/>
				</apex:column>
    			<apex:column headerValue="Quota">
			    	<apex:inputField value="{!key.QuotaAmount}"/>
			    </apex:column>
			    <apex:column headerValue="Date">
			    	<apex:outputField value="{!key.StartDate}"/>
			    </apex:column>
			</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>

Thank's for the help :)
 
Hi,

When adding metadata to a project, our Managed Package is missing from the src folder and I cannot see any of the objects.

I can see the managed package in 'Referenced Packages' but you cannot modify anything in there.

Is there anyway these can be included in the project as I can modify the objects within the web interface.

Thanks
I've started writing a Test Case so I can deploy my trigger. These are both for custom objects, however these are also on a managed package.

I am getting the following error when executing my test case:
 
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, pse.handleTimecardHeaderChange: execution of AfterInsert

caused by: System.NullPointerException: Attempt to de-reference a null object

I assume there is a perticular field which is used in an existing Trigger called pse.handleTimecardHeaderChange. However it has not been made mandatory, therefore the field is null?

If I am correct, how can I go about troubleshooting this as when I create the record through the Page it works fine and I cannot see any other fields that are populated by default.

Thanks