• WEN JIE
  • NEWBIE
  • 164 Points
  • Member since 2011

  • Chatter
    Feed
  • 5
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 48
    Questions
  • 122
    Replies
We have run into an interesting problem; we are creating a table of AccountContactRelations for the users to edit fields from the account, Contact, and Account Contact relation for mulitple accounts they are assigned. 

here is our Query:
List<AccountContactRelation> a = [SELECT id, AccountId, Account.Name, Contact.LastName, Roles FROM AccountContactRelation]

We display these to the user for them to quickly edit, but the issue comes when we need to save the records. how would we be able to save Account.Name and Contact.LastName?

We used a lot salesforce RESTful APIs in our platform. We now planning to make a china version of our product. Are there any APIs or Integration not available in China except for Google and Facebook related products?

Could you remain us will there be any differences in the general developping process?

Thanks

I have a custom object that has a Visualforce page override for View, Edit, and New. When creating new standalone versions of that object, the visualforce page works fine.

However, if I am creating that object via a lookup on another object, the standard page shows up instead! It also shows up in a modal window instead of a new window.

I feel this modal window is the issue. How do I force the new object creation from a lookup use the visualforce page instead of the default page?
I have method which returns  static List<SObject> . How can i retrieve retruned sobject.

 
Please help to resolve my error.


Line: 772, Column: 1
System.LimitException: Too many SOQL queries: 101

My method

public class ViewQAAMController {

public void queryOperation()
    {
        String weekData = '20/07/2020 - 24/07/2020';
        list<String> lstSplitDate1 = new list<String>();
        lstSplitDate1.clear();
        lstSplitDate1 = weekData.split(' - ');
        for(String s : lstSplitDate1)
        {
            System.debug('The date is '+s);
        }
        
        list<QAAM_Weekly_Planner__c> queryData = [select Week_Start_Date__c, Availability__c, ReasonAvailability__c, Work_Hours__c, Pre_Vet_Reviews__c, BAU_File_Reviews__c, Debriefs__c, File_Selection__c, Other_work__c, Other_work_Estimate__c, Total_Work_Time__c, Team_Meeting__c, Huddle__c, Quarterly_Updates__c, Governance_Forums__c, Performance_Reviews__c, Tea_Breaks__c, CPD_e_Learning_Maintenance__c, Coaching__c, PD_Days__c, One_on_Ones__c, Weekly_Tracker_preparation__c, Business_Communications__c, Other__c, Other1__c, Other2__c, Project_Time__c, Other_Time__c, Project_Time_Description__c, Other_Time_Description__c, Shrinkage_time__c, Available_Time__c, Availability_Checking__c, id, Week__C from QAAM_Weekly_Planner__c where Week__C =: weekData];
        list<String> weekDataStatic = new list<String>{'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'};
            integer i=0;
        for(QAAM_Weekly_Planner__c q : queryData)
        {
            
    AvailabilityMap.put(weekDataStatic[i], q.Availability__c);
     //Availabity Map
    CommentsMap.put(weekDataStatic[i], q.ReasonAvailability__c);
     WorkHoursMap.put(weekDataStatic[i], q.Work_Hours__c);
    //Core Categories Map
     EmpMap.put(weekDataStatic[i], q.Pre_Vet_Reviews__c);
     BAUFileReviewsMap.put(weekDataStatic[i], q.BAU_File_Reviews__c);
     DebriefsMap.put(weekDataStatic[i], q.Debriefs__c);
     FileSelectionMap.put(weekDataStatic[i], q.File_Selection__c);
     OtherworkMap.put(weekDataStatic[i], q.Other_work__c);
     OtherworkEstimation.put(weekDataStatic[i], q.Other_work_Estimate__c);
        TotalWorkTime.put(weekDataStatic[i], q.Total_Work_Time__c);
    //Shrinkage Categories Map
     TeamMeetingMap.put(weekDataStatic[i], q.Team_Meeting__c);
     HuddleMap.put(weekDataStatic[i], q.Huddle__c);
     QuarterlyUpdatesMap.put(weekDataStatic[i], q.Quarterly_Updates__c);
     GovernanceForumsMap.put(weekDataStatic[i], q.Governance_Forums__c);
     PerformanceReviewsMap.put(weekDataStatic[i], q.Performance_Reviews__c);
     TeaBreaksMap.put(weekDataStatic[i], q.Tea_Breaks__c);
     LearningMaintenanceMap.put(weekDataStatic[i], q.CPD_e_Learning_Maintenance__c);
     CoachingMap.put(weekDataStatic[i], q.Coaching__c);
     PDDaysMap.put(weekDataStatic[i], q.PD_Days__c);
     OneonOnesMap.put(weekDataStatic[i], q.One_on_Ones__c);
     WeeklyTrackerpreparationMap.put(weekDataStatic[i], q.Weekly_Tracker_preparation__c);
     BusinessCommunicationsMap.put(weekDataStatic[i], q.Business_Communications__c);
     OtherMap.put(weekDataStatic[i], q.Other__c);
     Other1Map.put(weekDataStatic[i], q.Other1__c);
     Other2Map.put(weekDataStatic[i], q.Other2__c);
     ProjecttimeMap.put(weekDataStatic[i], q.Project_Time__c);
     OthertimeMap.put(weekDataStatic[i], q.Other_Time__c);
    ProjecttimeDesMap.put(weekDataStatic[i], q.Project_Time_Description__c);
    OthertimeDesMap.put(weekDataStatic[i], q.Other_Time_Description__c);
    ShrinkageTimeMonMap.put(weekDataStatic[i], q.Shrinkage_time__c);
    //Available Hours
    AvailMonMap.put(weekDataStatic[i], q.Available_Time__c);
    CheckMonMap.put(weekDataStatic[i], q.Availability_Checking__c);
            i++;
        }
    }

 public void EmpMapSecValues()
    {
        EmpMap_Monday = EmpMap.get('Monday');
        EmpMap_Tuesday = EmpMap.get('Tuesday');
        EmpMap_Wednesday = EmpMap.get('Wednesday');
        EmpMap_Thursday = EmpMap.get('Thursday');
        EmpMap_Friday = EmpMap.get('Friday');
        System.debug(EmpMap_Monday + '-' +EmpMap_Tuesday  + '-' + EmpMap_Wednesday + '-' +EmpMap_Thursday  +'-' +EmpMap_Friday);
    }

}

I call this in 

ViewQAAMController obj = new ViewQAAMController();
obj.queryOperation();
obj.EmpMapSecValues();

and I get the error Line: 772, Column: 1 System.LimitException: Too many SOQL queries: 101

Line 772 is: integer i=0;

Regards
Karthic Sankar V P
Hi all,

I'm new to apex triggers and had posted in the community to get a trigger to create a field that summarizes Opportunities Product Families.  I was so excited when a wondeful community member was able to help. The code works create in my sandbox.  I attempted to do a change set to move into production but have been unable.  I submitted a case to Salesforce support and they recommded to post this forum since we are not on a Premier Sucess plan.

Code:
trigger populateProductFamily  on OpportunityLineItem (after Insert,before delete) {


if((trigger.IsAfter  && trigger.IsInsert)  || (trigger.IsBefore  && trigger.IsDelete)  )      // run after insert and before delete


{
//map to hold product family for a gven oppty
Map<id,Set<String>> oppprodFamilyMap = new Map<id,Set<String>>();
//get all oppty id
List<id> oppId =  new List<Id>();
List<opportunitylineitem> triggerList = new List<opportunitylineitem>();
if(trigger.IsDelete)
{  system.debug('in delete');
triggerList = trigger.old;
}

else
{
triggerList = trigger.new;
}


for (opportunitylineitem ol : triggerList )  {

   oppId.add(ol.opportunityid);

}

// query all opportunity for opportunitylineitem inserted



List<opportunity> oppList = [select id ,Opportunity_Product_Family__c from opportunity where id in :oppId];




// query all opportunitylineitem linked with opportunity of current opportunitylineitem
//we need this so that we can get all product family for a a given oppty

List<opportunitylineitem> olList  =  new List<opportunitylineitem>();

if(trigger.IsDelete) {
olList = [select id,opportunityid,product2.family  from opportunitylineitem where opportunityid in :oppList  and id not in  :triggerList  ];

}

else

{
olList = [select id,opportunityid,product2.family  from opportunitylineitem where opportunityid in :oppList  ];

}

system.debug('---ollist' + olList  );


//now we need to separate productfamily by opportunity


for (opportunitylineitem ol : olList )  {

IF(ol.product2.family  != null)  {
if(oppprodFamilyMap.get(ol.opportunityid) != null)  {

Set<String>  pFamilySet   = oppprodFamilyMap.get(ol.opportunityid);
pFamilySet.add(ol.product2.family);
oppprodFamilyMap.put(ol.opportunityid,pFamilySet);

}

else {
 Set<String> pFamilySet = new Set<String> ();
 pFamilySet.add(ol.product2.family);
oppprodFamilyMap.put(ol.opportunityid,pFamilySet);


}

}



}



// now we have got all productfamily for a given oppty.
//we need to concat  and update field


  //opplist to update
  
  List<opportunity> oppListToUpdate = new List<opportunity>();


for(opportunity  o : oppList)  



List<String>  pFamilyList = new List<String>(oppprodFamilyMap.get(o.Id));
String pFamily  = string.join(pFamilyList ,',');

o.Opportunity_Product_Family__c  = pFamily;
oppListToUpdate.add(o);

 


}


if(oppListToUpdate.size()>0)

update  oppListToUpdate;







}      

}

Error - Code Coverage Failure
Your code coverage is 0%. You need at least 75% coverage to complete this deployment.
populateProductFamily

I'm sure I have to change the sandbox, then the change set and try to deploy again into but everything I've tried fails.  Any help would be greatly appreciated.  
Hi Everyone,

if anyone find error in my apex class and please guide me.Actually i was new to write a programs.thanks you very much for helping me.

Apex class:

@RestResource(urlMapping='/DeleteInfo/*')
global class DeleteInfo {
@HttpPost
    global static String doPost() {
        String responseJSON;
        if (RestContext.request.requestBody != null) {
            String requestStatus;
            String reqBody = RestContext.request.requestBody.toString();
            String ParentId = null;
            Request Request = new Request();
            String environmentCode = Utility.getEnvironmentCode(UserInfo.getUserName());
            
            try {
                Req req = (Req)JSON.deserialize(reqBody, DeleteInfo.Req.class);
                Request = req.Request;
                
                if (Request.Parent != null) {
                    if (Request.Parent.StarID != null && Request.Parent.StarID != '') {
                        String ParentStarID = Request.Parent.StarID + '__' + environmentCode;
                        List<Hub_Parent__c> ptList = [select Id from Hub_Parent__c where StarID__c = :ParentStarID Limit 1];
                        
                        if (ptList.size() > 0) {
                            Hub_Parent__c objParent = ptList[0];
                            ParentId = objParent.Id;
                            
                            ParentDataDelete.DataDelete(objParent.Id);
                            
                            //List<ParentPrescription__c> lstParentPrescription = [select Id, Status__c from ParentPrescription__c Where Parents__c = :ParentId order by RxExpirationDate__c desc NULLS LAST, LastModifiedDate Desc limit 1];
                            
                            /*if (objParent.Prescriptions__r.size() > 0) {
                                ParentPrescription__c objParentPrescription = objParent.Prescriptions__r[0];
                                if (Request.Prescription.Status != null && (Request.Prescription.Status == 1 || Request.Prescription.Status == 2)) {
                                    String prescriptionStatus = Request.Prescription.Status == 1 ? 'Active' : 'Inactive';
                                    if (prescriptionStatus != objParentPrescription.Status__c) {
                                        objParentPrescription.Status__c = prescriptionStatus;
                                        update objParentPrescription;
                                    }
                                    responseJSON = InboundTransactionResponse.GetSucessResponse(Request.Header.TransactionType, Request.Header.TimeStamp, Request.Header.FileID, Request.Prescription.StarID);
                                    requestStatus = 'Success';
                                }
                                else {
                                    responseJSON = InboundTransactionResponse.GetErrorResponse(Request.Header.TransactionType, Request.Header.TimeStamp, Request.Header.FileID, Request.Prescription.StarID, 'Status', '0056', 'Invalid Prescription Status');
                                    requestStatus = 'Failure';
                                }
                            }
                            else {
                                responseJSON = InboundTransactionResponse.GetErrorResponse(Request.Header.TransactionType, Request.Header.TimeStamp, Request.Header.FileID, Request.Prescription.StarID, 'Prescription', '0056', 'Prescription doesn\'t exists in system for the Parent');
                                requestStatus = 'Failure';
                            }*/
                            responseJSON = InboundTransactionResponse.GetSucessResponse(Request.Header.TransactionType, Request.Header.TimeStamp, Request.Header.FileID, Request.Parent.StarID);
                            requestStatus = 'Success';
                        }
                        else {
                            responseJSON = InboundTransactionResponse.GetErrorResponse(Request.Header.TransactionType, Request.Header.TimeStamp, Request.Header.FileID, Request.Parent.StarID, 'StarID', '0056', 'StarID doesn\'t exists in system');
                            requestStatus = 'Failure';
                        }
                    }
                    else {
                        responseJSON = InboundTransactionResponse.GetErrorResponse(Request.Header.TransactionType, Request.Header.TimeStamp, Request.Header.FileID, null, 'StarID', '001', 'StarID is a required field.');
                        requestStatus = 'Failure';
                    }
                }
                else {
                    responseJSON = InboundTransactionResponse.GetErrorResponse(Request.Header.TransactionType, Request.Header.TimeStamp, Request.Header.FileID, null, 'Parent', '001', 'Invalid request format.');
                    requestStatus = 'Failure';
                }
                BlueStarTransactionDetails.CreateInboundTransactionRequest(Request.Header.TransactionType, Request.Header.FileID, requestStatus, reqBody, responseJSON, null, null, null, environmentCode);
            }
            catch (Exception ex) {
                System.debug('Delete Exception: ' + ex.getMessage());
                String fileId;
                if (Request.Header != null && Request.Header.FileID != null) {
                    fileId = Request.Header.FileID;
                }
                else {
                    fileId = 'Unknown';
                }
                BlueStarTransactionDetails.CreateInboundTransactionRequest(Request.Header.TransactionType, fileId, 'Exception', reqBody, ex.getMessage(), null, null, null, environmentCode);
                if(Request != null && Request.Header != null){
                    responseJSON = InboundTransactionResponse.GetErrorResponse(Request.Header.TransactionType, Request.Header.TimeStamp, Request.Header.FileID, null, 'Error', '0056', ex.getMessage());
                }else{
                    responseJSON = ex.getMessage();
                }
            }
        }
        return responseJSON;
    }
    
    public class Parent {
        public String StarID {get;set;}
    }
    
    public class Header {
        public String TransactionType {get;set;}
        public String TimeStamp {get;set;}
        public String FileID {get;set;}
    }
    
    public class Request {
        public Parent Parent {get;set;}
        public Header Header {get;set;}
    }
    
    public class Req {
        public Request Request {get;set;}
    }
}


Test Class for above Apex class:

@isTest
public class DeleteInfo_Test {
    static testMethod void TestDeleteInfo(){
        
        Test.startTest();
        HubTestController.createCustomSettings();
        //User usr = [Select Id from User where UserName = 'bluestar@welldocinc.com.sfdev4' Limit 1];
        List<User> usr = [Select Id,UserName from User where Name = 'bluestar bluestar' Limit 1];
        system.runAs(usr[0]){
            HubTestController.createEnviornmentSettingsWithUserName(usr[0].UserName);
            Hub_parent__c parent = new Hub_parent__c();
            parent.GivenName__c = 'Mangesh';
            parent.SampleCode__c = 'SCA1556329';
            parent.FamilyName__c = 'K';
            parent.Status__c = 'SRF Incomplete';
            parent.StarID__c ='StarID__bst';
            parent.FamilyName__c = 'K';
            parent.DOB__c = System.today();
            parent.Gender__c = 'M';
            
            insert parent;  
            RestRequest req = new RestRequest();
            RestResponse res = new RestResponse();
            
            String str ='{"Request":{"Header":{"TransactionType":"DeleteInfo","TimeStamp":"03-15-2016 12:09:15:252","FileID":"DeleteInfo.03152016120915252"},"parent":{"StarID":"StarID","Status":"Pending"}}}';
            req.requestURI = '/DeleteInfo/*';  
            req.httpMethod = 'Post';
            RestContext.request = req;
            RestContext.request.requestBody = Blob.valueOf(str);
            RestContext.response = res;
            String results = DeleteInfo.doPost();
            
            str = '{"Request":{"Header":{"TransactionType":"DeleteInfo","TimeStamp":"03-15-2016 12:09:15:252","FileID":"DeleteInfo.03152016120915252"},"parent":{"StarID":"StarID","AccountCode":"WD","SampleCode":"SampleCode"}}}';
            req.requestURI = '/DeleteInfo/*';  
            req.httpMethod = 'Post';
            RestContext.request = req;
            RestContext.request.requestBody = Blob.valueOf(str);
            RestContext.response = res;
            DeleteInfo.doPost();
            
            str = '{"Request":{"Header":{"TransactionType":"DeleteInfo","TimeStamp":"03-15-2016 12:09:15:252","FileID":"DeleteInfo.03152016120915252"},"parent":{"StarID":"StarID","AccountCode":"WD","SampleCode":"SampleCode"}}}';
            req.requestURI = '/DeleteInfo/*';  
            req.httpMethod = 'Post';
            RestContext.request = req;
            RestContext.request.requestBody = Blob.valueOf(str);
            RestContext.response = res;
            DeleteInfo.doPost();
            
            Str = '{"Request":{"Header":{"TransactionType":"DeleteInfo","TimeStamp":"03-15-2016 12:09:15:252","FileID"!=""},"parent":{"StarID"!="","AccountCode"!="","SampleCode"!=""}}}';
            req.requestURI = '/DeleteInfo/*';  
            req.httpMethod = 'Post';
            RestContext.request = req;
            req.requestBody = Blob.valueOf(str);
            RestContext.response = res;
            DeleteInfo.doPost();

            Test.stopTest();
        }
    }
}


Here i was facing issue was code was almost covered but while run the test class i was showing error.

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


if anyone please help me.


Thanks INadvance,
RajuBalaji