• venturec35
  • NEWBIE
  • 0 Points
  • Member since 2009

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

I'm building a retURL string in a test method, but am having trouble with the retURL portion.

 

here is the code

/* Build the Building record */
Building__c bldg = new Building__c();
bldg.name = '|Test1';
bldg.RecordTypeId = lstRcrdTyp[0].Id;
Database.insert(bldg);
        
/* Edit the Building that was just created */
PageReference pageRef = Page.BuildingEditSelect;
Test.setCurrentPage(pageRef);
ApexPages.currentPage().getParameters().put('id', bldg.Id);
cntrBuildingSelect controller = new cntrBuildingSelect(new ApexPages.StandardController(bldg));

retURL = '/' + bldg.Id;

returnURL = new PageReference('/apex/BuildingEditRCx');
returnURL.getParameters().put('id', bldg.Id);
returnURL.getParameters().put('retURL', retURL);
returnURL.getParameters().put('scontrolCaching', scontrolCaching);
returnURL.getParameters().put('sfdc.override', '1');

 

 

I expected the retURL string to be something like:

retURL=/a0JS00000001lzS

 

but I'm actually getting:

retURL=%2Fa0JS000000025QNMAY

 

The %2F at the beginning of the Id is throwing off my test coverage.

 

Anyone have a possible solution for this?

 

Thanks.

Does anyone know where I can get or download a Visualforce Component / Attribute Hierarchy? It would be nice to know the top component and related attribute values needed if I am to use another component later on.

 

Thanks.

I'm building a retURL string in a test method, but am having trouble with the retURL portion.

 

here is the code

/* Build the Building record */
Building__c bldg = new Building__c();
bldg.name = '|Test1';
bldg.RecordTypeId = lstRcrdTyp[0].Id;
Database.insert(bldg);
        
/* Edit the Building that was just created */
PageReference pageRef = Page.BuildingEditSelect;
Test.setCurrentPage(pageRef);
ApexPages.currentPage().getParameters().put('id', bldg.Id);
cntrBuildingSelect controller = new cntrBuildingSelect(new ApexPages.StandardController(bldg));

retURL = '/' + bldg.Id;

returnURL = new PageReference('/apex/BuildingEditRCx');
returnURL.getParameters().put('id', bldg.Id);
returnURL.getParameters().put('retURL', retURL);
returnURL.getParameters().put('scontrolCaching', scontrolCaching);
returnURL.getParameters().put('sfdc.override', '1');

 

 

I expected the retURL string to be something like:

retURL=/a0JS00000001lzS

 

but I'm actually getting:

retURL=%2Fa0JS000000025QNMAY

 

The %2F at the beginning of the Id is throwing off my test coverage.

 

Anyone have a possible solution for this?

 

Thanks.

Let me preface this by saying that I am not all that experienced with Apex - I have dabbled enough to be dangerous, but do not have a robust understanding. Tried a search related to this issue and came up with nothing, but my apologies if I overlooked a previous related post.

 

Challenge with Contract Object:

 

I need a way to pull the Primary Contact information from the Related Contact list to the Contract.  I was able to build a trigger that brings the Primary Contact ID onto the Contract from the Related Contact Object, however when trying to populate the Contact Name affiliated with the Primary Contact ID I've hit a wall. Since the ContractContactRole object does not have a built in reference to the contact name I've got a bit more digging to do other than what I have existing - can't simply replicate the trigger and substitute a name field that doesn't exist on the object.

 

Need for the Primary Contact on the Contract: We have a WIL driven button that is designed to pull the Primary Contact name into a specified email template - in place for ease of use for the end user and a check to ensure the end user does not  select the wrong contact on the contract for this email. 

 

Right now the link is pulling the Contact ID, which obviously doesn't work to personalize the salutation in our email.  I need the Primary Contact ID on the Contract for the WIL to properly populate the email recipient, but I also need another field on the Contract that can serve as the merge field on the email template.

 

I tried a formula field, but no luck.  I think I have to go trigger route, but then it gets into an area of timing, which I have no idea how to solve.

 

 

Here is my Trigger for the Primary Contact ID:

 

 

trigger ShowContactID on Contract (before update) {
for (Contract c : Trigger.new) {
ContractContactRole contactRole =
[select ContactID from ContractContactRole where IsPrimary = true and ContractId = :c.id];

if (contactRole != null) {
c.Primary_Contact_ID__c = contactRole.ContactID;
}
}
}

 

 

 

 

Here is my attempt at a formula to populate the Contact Name:

 

 

IF(
Primary_Contact_ID__c = Contact_Lookup__r.Id ,
Contact_Lookup__r.FirstName ,
"Recipient"
)

 

 

 

 Thanks in advanced for helping me figure this out!

 

 

Does salesforce Apex support iterating over a map using a for loop?