• Muhammad Wasim
  • NEWBIE
  • 55 Points
  • Member since 2014

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

Hi Guys

I want to understand a concept. I have 4 custom objects.

  1.  Position
  2.  Candidate
  3.  Job_Application
  4.  Review

The Job_Application object has two master-detail relationships. One is related to Position and the other is related to Candidate. Now if I want to create another master-detail relationship in the Job_Application object. Framework will not allow me to do that, because we have limit of two master-detail relationships per object.

I'm trying to create a master-detail relationship in the Review object with the master Job_Application and the detail Review object. But when I choose master-detail relationship type and go to the next page to relate it with an object(master). I do not find Job_Application object in that related to list. Why? Is it possible to create a master-detail relationship with such an object which is already detail of two objects? It could be the master of another object? I think it should be possible but don't know what is the reason behind that I'm unable to see the Job_Application object in related to list. Please guide.

Thanks.

If any one of you created the Force.com default Recruiting app. I have a simple yet weird question for you guys. I can't see any Job_Application object in the related to list.

Let's start by adding the master-detail relationship field, which will relate our Review object with the Job Application object. To create the master-detail relationship field, access the Review object detail page.

4. Select Master-Detail Relationship, and click Next.
5. In the Related To drop-down list, choose Job Application, and click Next.

So I'm stuck at 5th point. I have Job Application object created already, which have two relationships in it, one with Position object and the other one is with Candidate object. Pleas help.
Hi Guys

I'm preparing myself for the Dev401 certification and following the workbooks provided by the salesforce. Don't know what kind of questions for that I have to prepare myself? I'm able to create basic application and have good understanding. Still I'm confused that I don't know the internals as the questions will be in the exam where they will not ask how to create an object, relationships etc.. Give me some tips and guide me towards the right track. I have to get it done as soon as possible. Please help.

Thanks.

Error Error: Unknown property 'Contact__c.Miles__c' referenced in MyMileagePage

 

<apex:page >
  <!-- Begin Default Content REMOVE THIS -->
  <h1>{!$User.FirstName}'s Mileage Perspective</h1>
  <apex:detail/>
  <apex:detail subject="{!Contact__c.Miles__c}" />   
     
</apex:page>
This is my test class: 

@IsTest(SeeAllData=true) 
public with sharing class TestInsertDefaultLineItems {
    static testMethod void validateTrigger() {
       Account acc= new Account(Name = 'testAcc', Description='testdesc');
       insert acc;

        //Case record in Test method. 
        Contact conObj = new Contact();
        conObj.lastname = 'testcon';
        conObj.AccountId = acc.id;
        insert conObj;
 
        Opportunity opp1 = new Opportunity (AccountId = acc.Id, Name = 'testOpp', CloseDate = System.today());
            insert opp1;
        
       /* PricebookEntry priceBookEntryNew = new PricebookEntry ();
        Product2 product = new Product2 ();
        PriceBook2 pb2 = new PriceBook2 (Name='Standard priceBook', Description='test');
        insert pb2;      
       List pricebookList = [SELECT Id FROM PriceBook2 WHERE IsStandard = true ];*/
        
     PricebookEntry priceBookEntryNew = new PricebookEntry();
        Product2 product = new Product2(); 
        PriceBook2 pb2 = new PriceBook2 (Name='Standard priceBook',Description = 'test');
        insert pb2;
        List <PriceBook2> pricebookList = [SELECT Id FROM PriceBook2 WHERE IsStandard = true];
        PriceBook2 pricebooktest = new PriceBook2 ();
        if (pricebookList !=null && pricebookList.size()>0)
            pricebooktest = pricebookList.get(0);
        product.name = 'Test';
        insert product;
        
        priceBookEntryNew.Product2Id = product.Id;
        priceBookEntryNew.PriceBook2Id = pricebooktest.Id;
        priceBookEntryNew.UnitPrice = 20.00;
        priceBookEntryNew.UseStandardPrice = false;
        priceBookEntryNew.isactive = true; 
        insert priceBookEntryNew;

        OpportunityLineItem oli = new OpportunityLineItem
            (OpportunityId = opp1.Id,
             PricebookEntryId = priceBookEntryNew.Id,
             Quantity = 1,
             UnitPrice = priceBookEntryNew.UnitPrice,
             
             ServiceDate = System.today()
            );
        insert oli;
    }
}
How do I create a trigger and trigger handler to auto assign a name for custom field on a custom object when a new record is created? The auto-assigned name should be randomly selected from a list of strings.
i have Postion and candidate object in my application candidate having status picklistfiled values are 
selected,Rejacted. i want to filter the selected records and rejected records for the position for that 
record pagelayout how ito achieve this help me   
 
Hi All,

I'm having an issue here with properly escaping a backslash in JSON.
I'm using System.JSON.deserialize() to parse some JSON and I have a value that is something like this

{"First Name" : "John \photographer"}

I realize the backslash needs to be escaped so I try changing the string to contain {"First Name" : "John \\photographer"} but when I try to deserialize this I get the following error

Unrecognized character escape 'p' (code 112) at [line:1, column:291]

To me this doesn't make any sense.  The first backslash should be escaping the second backslash and so there should not be any confusion with the "p" character.  

So far the only way I can get the deserialize method to run properly is by changing the string to be {"First Name" : "John \\\\photographer"}.  However as you would expect this yeilds the result "John \\photographer" as the value when it is displayed in the package which is not what I want.

Any help here?
When I run the test class for the one trigger ,the system throws an as :
System.LimitException: Too many SOQL queries: 101

Trigger.MergeLeadTrigger: line 276, column 1

Trigger.Accountduplicate: line 6, column 1

The Trigger which im running :
trigger CampaignMemberSyncStatus on CampaignMember (after update) {
    // Sync response status on Campaign Member to lead or contact

    // Look for status changes
    List<Id> relatedIDs = new List<ID>();
    List<Id> modifiedIDs = new List<ID>();
 
    // Get the list of IDs for campaignmembers whose status changed
    for(CampaignMember cm : Trigger.new) {
        if(cm.Response_Status__c != trigger.oldMap.get(cm.Id).Response_Status__c)
        {
            modifiedIDs.add(cm.Id);
            if(cm.ContactId != null) {
                relatedIDs.add(cm.ContactId);
            } else {
                relatedIDs.add(cm.LeadId);
            }
        }
    }
    if(modifiedIds.size() == 0) return;     /// No modified responses
    
    // Now pull the list of related leads and contacts
    Map<id,Lead> RelatedLeads;
    Map<id,Contact> RelatedContacts;
    RelatedLeads = new Map<ID,Lead>([Select id, Disqaulified_Reason__c, Status from Lead where Id in :relatedIDs]);
    RelatedContacts = new Map<ID,Contact>(
        [Select id, Status__c, Lead_Score__c, Campaign_Score__c, Account.Customer_Status__c, Admin_Nurture_Timeout__c from Contact where Id in :relatedIDs]);
    
    // Build lists of leads or contacts to update
    Map<ID,Lead> ModifiedLeads = new Map<ID,Lead>();
    Map<ID,Contact> ModifiedContacts = new Map<ID,Contact>();
    
    Map<String, CMStatusSettings__c> statusmapping = CMStatusSettings__c.getall();
    
    // Now update the stautus
    for(id cmid : modifiedIDs) {
        CampaignMember cm = trigger.newMap.get(cmid);
        Boolean wasupdated;
        if(cm.ContactId != null) {
            wasupdated = CampaignMemberFunctions.SyncStatus(cm, null, RelatedContacts.get(cm.ContactId), statusmapping);
            if(wasupdated) ModifiedContacts.put(cm.ContactID,RelatedContacts.get(cm.ContactId));
        } else {
            wasupdated = CampaignMemberFunctions.SyncStatus(cm, RelatedLeads.get(cm.LeadId), null, statusmapping);
            if(wasupdated) ModifiedLeads.put(cm.LeadId,RelatedLeads.get(cm.LeadId));
        }
    }
    if(ModifiedLeads.size()>0) update ModifiedLeads.values();
    if(ModifiedContacts.size()>0) update ModifiedContacts.values();
    
    
}
Test Class :
@isTest
public class TestCampaignMemberSync 
{

    static testMethod void TestStatusUpdates() 
    {
    Account genericaccount = new Account(Name = 'someaccount');
    insert genericaccount;

        Lead ld1 = new Lead(Company='colead1',LastName='colead1');
        Lead ld2 = new Lead(Company='colead2',LastName='colead2');
        Contact ct1 = new Contact(LastName='cocontact1', AccountID = genericaccount.Id);
        Contact ct2 = new Contact(LastName='cocontact2', AccountID = genericaccount.Id);
        Campaign cam = new Campaign(Name='campname');
        insert cam;
    insert ld1;
    insert ld2;
    insert ct1;
    insert ct2;
        CampaignMember mc1 = new CampaignMember(CampaignId = cam.Id, LeadId=ld1.Id, Buyer__c='a', user__c='b');
        CampaignMember mc2 = new CampaignMember(CampaignId = cam.Id, LeadId=ld2.Id, Buyer__c='a', user__c='b');
        CampaignMember mc3 = new CampaignMember(CampaignId = cam.Id, ContactId=ct1.Id, Buyer__c='a', user__c='b');
        CampaignMember mc4 = new CampaignMember(CampaignId = cam.Id, ContactId=ct2.Id, Buyer__c='a', user__c='b');
    List<CampaignMember> cms = new List<CampaignMember>();
    cms.add(mc1);cms.add(mc2);cms.add(mc3);cms.add(mc4);
    
    
        insert cms;
        List<Id> cmids = new List<id>();
    for(CampaignMember thiscm: cms)
    {
      cmids.add(thiscm.id);
    }
    
    ld1.admin_CMSourceId__c = mc1.id;
    update ld1;  // Needed later to simulate the button click on conversion
    ld2.admin_CMSourceId__c = mc2.id;
    update ld2; // Needed later to simulate the button click on conversion
    
    // Initialize the opp for later creation from CampaignMember
    Opportunity Opp = new Opportunity(CloseDate = Date.Today().addDays(30), AccountId = genericaccount.Id,
        Name='someopp', StageName='Selected' );
        
        Test.StartTest();
        mc1.Response_Status__c = 'Working';
        mc2.Response_Status__c = 'Disqualified';
        mc2.Disqualified_Reason__c = 'no budget';
        mc3.Response_Status__c = 'Working';
        mc4.Response_Status__c = 'Disqualified';
        mc4.Disqualified_Reason__c = 'no budget';
        mc4.Do_not_reassign_to_Landings__c = true;
        
        update cms;
       Test.StopTest();    
        
        List<CampaignMember> mcres = [Select Id, Response_Status__c, Contact.Admin_Nurture_Timeout__c , Contact.Status__c, Lead.Status, Do_not_reassign_to_Landings__c 
          from CampaignMember where Id = :cmids ];
        for(CampaignMember cm: mcres) {
          System.debug('Response ' + cm.Response_Status__c + ' lead status:' + cm.Lead.Status + ' contact status:' + cm.Contact.Status__c );
          System.debug('Nurture date:' + mcres[3].Contact.Admin_Nurture_Timeout__c);
        }
    //System.assertEquals(mcres[3].Do_not_reassign_to_Landings__c, mcres[3].Contact.Do_not_reassign_to_Landings__c);
 
     }
     
     
    static testMethod void TestConversionsNoOpp() 
    {
        Account genericaccount = new Account(Name = 'someaccount');
        insert genericaccount;

            Lead ld1 = new Lead(Company='colead1',LastName='colead1');
            Lead ld2 = new Lead(Company='colead2',LastName='colead2');
            ld2.OwnerId = UserInfo.getUserId();
            Campaign cam = new Campaign(Name='campname');
            insert cam;
            insert ld1;
            insert ld2;
            CampaignMember mc1 = new CampaignMember(CampaignId = cam.Id, LeadId=ld1.Id, Buyer__c='a', user__c='b');
            CampaignMember mc2 = new CampaignMember(CampaignId = cam.Id, LeadId=ld2.Id, Buyer__c='a', user__c='b');
            List<CampaignMember> cms = new List<CampaignMember>();
            cms.add(mc1);
            cms.add(mc2);
        
            insert cms;
            List<Id> cmids = new List<id>();
       
        
        ld1.admin_CMSourceId__c = mc1.id;
        update ld1;  // Needed later to simulate the button click on conversion
        ld2.admin_CMSourceId__c = mc2.id;
        update ld2; // Needed later to simulate the button click on conversion
        
        // Initialize the opp for later creation from CampaignMember
        Opportunity Opp = new Opportunity(CloseDate = Date.Today().addDays(30), AccountId = genericaccount.Id,
            Name='someopp', StageName='Selected' );
            
            mc1.Response_Status__c = 'Working';
            mc2.Response_Status__c = 'Disqualified';
            mc2.Disqualified_Reason__c = 'no budget';
             
            
            update cms;
            
            // We're checking CampaignMemberOpportunityInsertTrigger here
            Opp.admin_CMSourceId__c = mc2.Id;  // Set the source ID
            insert Opp;

            Test.StartTest();

            
            // Now let's do a lead convert
         Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(ld2.Id);
        lc.setConvertedStatus('Converted - Existing Opportunity');
        lc.setDoNotCreateOpportunity(true);
        lc.setOwnerId(UserInfo.getUserId());
        Database.LeadConvertResult lcr2 = Database.convertLead(lc);
            
              Test.StopTest();    
            try
            {
             }
            catch(Exception ex)
            {
              System.Debug('Exception during TestConversionsNoOpp StopTest (async error)' + ex.getMessage());
            }
     
         System.assert(lcr2.isSuccess());
            CampaignMember mc2b = [Select Id,Response_Status__c, Opportunity_Create_Date__c, Opportunity_Name__c, Buyer__c, User__c from CampaignMember where Id = :mc2.id];
        Lead convertedleadinfo = [Select Id, isConverted, Status from Lead where id = :ld2.Id];
        System.Debug('original leadid:' + ld2.Id + ' leadid result id:' + lcr2.getLeadId());
        System.Debug('Converted lead isconverted:' + convertedleadinfo.IsConverted + ' status:' + convertedleadinfo.Status);
           system.assertEquals('Converted - Existing Opportunity', mc2b.Response_Status__c);
     }
 }
The Error Lines Of other Triggers are
Error line  for MergeLead Trigger :

conrecords=[select id , Rep_Managing_Partner_del__c from Contact where id in: getconid1 and Rep_Managing_Partner_del__c !=null];

Error line  for AccountDuplicateTrigger :

  lstusr  =[SELECT Id,Name,Profile.Name FROM User WHERE Id=:UserInfo.getuserId()];
Any help very much appreciated.



 
If any one of you created the Force.com default Recruiting app. I have a simple yet weird question for you guys. I can't see any Job_Application object in the related to list.

Let's start by adding the master-detail relationship field, which will relate our Review object with the Job Application object. To create the master-detail relationship field, access the Review object detail page.

4. Select Master-Detail Relationship, and click Next.
5. In the Related To drop-down list, choose Job Application, and click Next.

So I'm stuck at 5th point. I have Job Application object created already, which have two relationships in it, one with Position object and the other one is with Candidate object. Pleas help.