• Saurabh Gupta Manras
  • NEWBIE
  • 55 Points
  • Member since 2014
  • Manras Technologies Private Limited

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 10
    Replies
Once I install unmanaged package from Apex Specialist Superbadge and check Challenge, I am getting below error.
In email I got below message after I installed unmanaged package -
Package: Trailhead Apex Superbadge (04t36000000i5UM)
Some components, such as custom objects, custom report types, and workflow rules, must be activated using the package deploy process, before they are available to your organization.


Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Validation Formula "Term_schedule_requires_subscription" Invalid (Field 00N5000000ASPDU is inaccessible. Please review all fields referenced by the formula. Context: common.config.entity.ValidationFormulaContext): []
public class TimeTableset_controller{
integer i=1;
integer count;
for(count=1;count<24;count++)
{
    if(count<12 || count>=12)
        if(count<12)
    system.debug(i+':00AM-'+(++i)+':00AM');
    if(count>=12)
        system.debug(i+':00PM-'+(++i)+':00PM');
    
}
}
Hello Community,
 
Looking for some assistance with loading test data via CSV files. I’m attempting to generate test data using the Test.LoadData method. In this circumstance, I’m loading, Users, Accounts and Campaigns. Users and Accounts load fine but when I attempt to load Campaign records, I get an error stating “Validation Errors While Saving Record(s)”. I have turned off all validation rules on the Campaign object and have taken my Campaign CSV data down to bare bones for experimentation purposes (inserting only one record with minimal fields).
 
The Campaign object has two Account lookup field and two user lookup fields. Although I have not been able to validate it, I’m thinking that the foreign id’s I’m using as references are only being considered directly after the insert. For example.
 
Step 1:
Load Users with numerically sequential ID’s i.e. 1,2,3,4,5,6. When loaded, the users are assigned actual 15 charter SF id’s .
 
Step 2:
Load Account data with numerically sequential ID’s i.e. 1,2,3,4,5,6. I also have a user lookup field that I have assigned via the foreign key (numerically sequential ID’s from step 1)
 
Step 3:
Load Campaign data and reference the users and Accounts via the assigned foreign id’s from step 1 & 2.
 
Step 3 will not work and throws a validation error described above. I am unable to get any further information from the logs and feel a bit stuck.
 
Anyone have an idea on the issue here?

Here is my code:
@isTest
public class TestUtilityClass {
    
    public static void CreateTestAccountsAndCampaigns() {
        list<SObject> dataList = new list<SObject>();
        dataList.addAll(Test.loadData(User.sObjectType,'TestData_User_MDO'));  
        dataList.addAll(Test.loadData(Account.sObjectType,'TestData_Accounts_Districts'));
        dataList.addAll(Test.loadData(Campaign.sObjectType,'TestData_Campaign_MD'));
    }        
}
 
@isTest
private class Test_OfficerStats_CampaignUpdate {
    
@testSetup static void setup() {
        id UserId = system.UserInfo.getUserId();
        user CurrentUser = [Select id from user where id = :UserId];
        
        system.runAs(currentUser){
            TestUtilityClass.CreateTestAccountsAndCampaigns();     
        }
        
    }
}
Here are my CSV files
User-added image
User-added image
User-added image

 
  • October 13, 2017
  • Like
  • 0

Hi

I want to write a VF page or component and user can add it to any page that he want.

I tried but found that VF page must define a specific controller or I can't add this VF page into any page(Account, Opportunity,...)

Is there a way to write a VF page/component once and use it anywhere?

 

Thank you so much

Hello, 

I have a situation in which I have to run a single query from 2 differenct unrelated custom objects and I actually have no clue how to do that in SOQL, as SOQL doesn't have the JOIN functionality. 

I have 2 Custom Object named: 1. jud_city_list__c and 2. jud_dlr_list__c. 
This is the SQL query which I want to access through SOQL.

SELECT `l`.`city`, `l`.`pref_dlr1`, `l`.`pref_dlr2`, `l`.`pref_dlr3`, `d`.`name`, `d`.`dlrid`, `d`.`state` 
AS `dlr_states`, `d`.`city` AS `dlr_city`, `d`.`ud_dlrid`
FROM `jud_city_list` `l`JOIN `jud_dlr_list` `d` ON `d`.`dlrid` IN (l.pref_dlr1,l.pref_dlr2,l.pref_dlr3)
WHERE `l`.`city` LIKE 'm%' ESCAPE '!'ORDER BY `l`.`city` ASC

where l - jub_city_list__c object
          d - jub_dlr_list__c object. 

I don't know how to get this SQL query into SOQL query. Do I have to write a wrapper class for this ? Or Is there any other possible way available to get this query written into SOQL ?

Thanks you so much in advance, looking for some serious help.

Regards,
Hardik B.
I try to build a REST API to receive JSON from another server.
The JSON sample like this.
{  
   "token":"1234",
   "od_order_id_str":"12345,
   "od_status":"test",
   "od_product_code":"test,
   "od_rate":"741",
   "od_deliver_status":"NOT_YET",
   "od_archive_policy_doc":"false",
   "od_contract_status":"NONE",
   "od_source":"B2B",
   "od_b2b_invalid_data":[  
      "U01",
      "U02",
      "U06"
   ],
   "ap_first_name":"jack",
   "ap_last_name":"wang",
   "ap_mobile":"0987654321",
   "ap_pid":"test",
   "ap_birthday":"1980-01-01",
   "ap_email”:”test@email",
   "ap_address_city_id":"19",
   "ap_address_area_id":"10",
   "ap_address":"test",
   "tr_transport":"Airplane",
   "tr_country_code":"JP",
   "tr_city_id":"0",
   "tr_purpose":"Tourism",
   "tr_start_date":"2017-09-18",
   "tr_start_hour":"00",
   "tr_start_min":"00",
   "tr_end_date":"2017-09-29",
   "tr_end_hour":"00",
   "tr_end_min":"00",
   "tr_period_days":"11",
   "pay_order_id":"8600000023",
   "policy_list":[  
      {  
         "po_ins_company_code":"TaiAn",
         "po_policy_id_str":"",
         "po_rate":"741",
         "insured_list":[  
            {  
               "in_relationship":"SELF",
               "in_last_name":"wang",
               "in_first_name":"jack",
               "in_pid":"test",
               "in_birthday":"1980-01-01",
               "in_rate":"741",
               "pa_package_type":"PACKAGE",
               "pa_package_name":"test",
               "in_taian_package":"B",
               "item_list":[  
                  {  
                     "it_is_primary":"true",
                     "it_ins_item_code":"ITEM_RESPONSE",
                     "it_ins_company_code":"",
                     "it_amount_code":"100",
                     "it_amount_name":"100",
                     "it_amount":"1000000",
                     "it_rate":"0",
                     "it_item_name":"test1"
                  },
                  {  
                     "it_is_primary":"true",
                     "it_ins_item_code":"ITEM_SAFE",
                     "it_ins_company_code":"TaiAn",
                     "it_amount_code":"200",
                     "it_amount_name":"200",
                     "it_amount":"2000000",
                     "it_rate":"184",
                     "it_item_name":"test2"
                  },
                  {  
                     "it_is_primary":"false",
                     "it_ins_item_code":"ITEM_MEDICAL_BILL",
                     "it_ins_company_code":"TaiAn",
                     "it_amount_code":"5萬",
                     "it_amount_name":"5萬",
                     "it_amount":"50000",
                     "it_rate":"12",
                     "it_item_name":"test3"
                  },
                  {  
                     "it_is_primary":"false",
                     "it_ins_item_code":"ITEM_MEDICAL_DAY",
                     "it_ins_company_code":"TaiAn",
                     "it_amount_code":"1000",
                     "it_amount_name":"1000",
                     "it_amount":"0",
                     "it_rate":"33",
                     "it_item_name":"test4"
                  },
                  {  
                     "it_is_primary":"false",
                     "it_ins_item_code":"ITEM_INCONVENIENT",
                     "it_ins_company_code":"TaiAn",
                     "it_amount_code":"商務",
                     "it_amount_name":"商務",
                     "it_amount":"0",
                     "it_rate":"429",
                     "it_item_name":"test5"
                  },
                  {  
                     "it_is_primary":"false",
                     "it_ins_item_code":"ITEM_SUDDEN_SICK",
                     "it_ins_company_code":"TaiAn",
                     "it_amount_code":"20萬",
                     "it_amount_name":"20萬",
                     "it_amount":"200000",
                     "it_rate":"83",
                     "it_item_name":"test6"
                  }
               ],
               "benef_list":[  
                  {  
                     "be_last_name":"wang",
                     "be_first_name":"father",
                     "be_pid":"test",
                     "be_relationship":"father"
                  },
                  {  
                     "be_last_name":"wang",
                     "be_first_name":"mother",
                     "be_pid":"test",
                     "be_relationship":"mother"
                  }
               ]
            }
         ]
      }
   ]
}

And I have created the apex structure like this.
public class Benef_list {
		public String be_last_name;
		public String be_first_name;
		public String be_pid;
		public String be_relationship;
	}
    
    public class Policy_list {
		public String po_ins_company_code;
		public String po_policy_id_str;
		public String po_rate;
		public List<Insured_list> insured_list;
	}
    
    //Request Model
    public class RequestModel
    {
        public String token;
		public String od_order_id_str;
		public String od_status;
		public String od_product_code;
		public String od_rate;
		public String od_deliver_status;
		public String od_archive_policy_doc;
		public String od_contract_status;
		public String od_source;
		public List<String> od_b2b_invalid_data;
		public String ap_first_name;
		public String ap_last_name;
		public String ap_mobile;
		public String ap_pid;
		public String ap_birthday;
		public String ap_email;
		public String ap_address_city_id;
		public String ap_address_area_id;
		public String ap_address;
        public String ap_update_info; 
		public String tr_transport;
		public String tr_country_code;
		public String tr_city_id;
		public String tr_purpose;
		public String tr_start_date;
		public String tr_start_hour;
		public String tr_start_min;
		public String tr_end_date;
		public String tr_end_hour;
		public String tr_end_min;
		public String tr_period_days;
		public String pay_order_id;
		public List<Policy_list> policy_list;
    }
    
    public class Item_list {
		public String it_is_primary;
		public String it_ins_item_code;
		public String it_ins_company_code;
		public String it_amount_code;
		public String it_amount_name;
		public String it_amount;
		public String it_rate;
		public String it_item_name;
	}

	public class Insured_list {
		public String in_relationship;
		public String in_last_name;
		public String in_first_name;
		public String in_pid;
		public String in_birthday;
		public String in_rate;
		public String pa_package_type;
		public String pa_package_name;
        public String in_taian_package;
		public List<Item_list> item_list;
        public List<Benef_list> benef_list;
	}

It can receive the data successfully, but the question is occurred on inserting or updating data.
In SFDC, I created 3 objects: Order, OrderItem, TravelCom.
Order is the parent of OrderItem, and OrderItem is the parent of TravelCom.
 
List<Order__c> orderList = [SELECT Id, Name, Account__c,
                                            (SELECT Id, Name, Order__c, relationship__c, 
                                            FROM OrderItems__r),
                                            (SELECT Id, Name ,Order__c, OrderItem__c,
                                            FROM TravelCom__r)
                                            FROM Order__c
                                            WHERE RecordTypeId = :orderRTList[0].Id
                                            AND Name = :tmpRequestModel.od_order_id_str];

The API can create these 3 objects well and insert the responding value on Order, OrderItem but TravelCom is always null.
This is what I wrote.
for (Policy_list objPolicy : tmpRequestModel.policy_list) 
                { 
                    for (Insured_list objInsured : objPolicy.insured_list) 
                
                    { 

                        tmpOrderItem.Insurance_No__c = objPolicy.po_policy_id_str;
                        
                     
                        upsert tmpOrderItem;
                        

                        
                        for(Item_list objItem : objInsured.item_list)
                        {
                                tmpTravelCom.Orderitem__c = tmpOrderItem.Id;

                           if(objItem.it_ins_item_code !=null)
                           {

                               	  if(objItem.it_ins_item_code == 'test1)
                                  {                                                              
                                       tmpTravelCom.TA001_amount__c = integer.valueOf(objItem.it_amount);
                                       tmpTravelCom.TA001_Price__c = integer.valueOf(objItem.it_rate);
                                  }
                          
                                  if(objItem.it_ins_item_code == 'test2' && tmpTravelCom.TA001_amount__c != null && tmpTravelCom.TA001_amount__c != null)
                                  {
                                       tmpTravelCom.TA002_amount__c = integer.valueOf(objItem.it_amount);
                                       tmpTravelCom.TA002_Price__c = integer.valueOf(objItem.it_rate);
                                     
                                  }
                                       
                                  if(objItem.it_ins_item_code == 'test3')
                                  {
                                       tmpTravelCom.TA003_amount__c = integer.valueOf(objItem.it_amount);
                                       tmpTravelCom.TA003_Price__c = integer.valueOf(objItem.it_rate);
                                              
                                  }
                                   
                              
                                   }
                               
                           } 
                           else
                           {	tmpResponseModel.status = '01';
                                tmpResponseModel.traceError = 'No Insured Item value!';
                           }

                        }
                        upsert tmpTravelCom;


                        
                    } 
                }

Can anyone correct me?
Thank you so much.
 
  • October 12, 2017
  • Like
  • 0