• Savvy Admin
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 9
    Replies
Hi,

I have the following JSON retrieved from a web service request. 
[
	{
		"WarrantyPremium_type_info": [
			"WarrantyPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"WarrantyPremium": null,
		"VehicleDescription_type_info": [
			"VehicleDescription",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"VehicleDescription": null,
		"TruckGapPremium_type_info": [
			"TruckGapPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"TruckGapPremium": null,
		"TotalAssistPremium_type_info": [
			"TotalAssistPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"TotalAssistPremium": {
			"StampDuty_type_info": [
				"StampDuty",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"false"
			],
			"StampDuty": 112.27,
			"Premium_type_info": [
				"Premium",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"false"
			],
			"Premium": 1235,
			"Gst_type_info": [
				"Gst",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"false"
			],
			"Gst": 102.07,
			"field_order_type_info": [
				"AvailablePaymentMethods",
				"CostExGst",
				"CoverTypeCode",
				"EstablishmentFee",
				"Gst",
				"Premium",
				"StampDuty"
			],
			"EstablishmentFee_type_info": [
				"EstablishmentFee",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"false"
			],
			"EstablishmentFee": 44,
			"CoverTypeCode_type_info": [
				"CoverTypeCode",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"0",
				"1",
				"true"
			],
			"CoverTypeCode": "TC1",
			"CostExGst_type_info": [
				"CostExGst",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"true"
			],
			"CostExGst": 500,
			"AvailablePaymentMethods_type_info": [
				"AvailablePaymentMethods",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"true"
			],
			"AvailablePaymentMethods": {
				"PaymentMethod_type_info": [
					"PaymentMethod",
					"http://services.fastr.com.au/Quotation/Data",
					null,
					"0",
					"-1",
					"true"
				],
				"PaymentMethod": [
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1279,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": null,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Full - Credit Card",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": null,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "CREDITCARD",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					},
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1279,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": null,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Full - Dealer Cheque",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": null,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "DEALERCHEQUE",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					},
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1279,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": null,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Full - Finance Company",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": null,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "FINANCECOMPANY",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					},
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1383.2,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": 12,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Monthly - Bank account",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": 115.27,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "PREMFUND12BA",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					},
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1383.2,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": 12,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Monthly - Credit Card",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": 115.27,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "PREMFUND12CC",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					}
				],
				"field_order_type_info": [
					"PaymentMethod"
				],
				"apex_schema_type_info": [
					"http://services.fastr.com.au/Quotation/Data",
					"true",
					"false"
				]
			},
			"apex_schema_type_info": [
				"http://services.fastr.com.au/Quotation/Data",
				"true",
				"false"
			]
		},
		"ServiceContractPremium_type_info": [
			"ServiceContractPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"ServiceContractPremium": null,
		"QuotationNumber_type_info": [
			"QuotationNumber",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"QuotationNumber": "Q14327612",
		"QuotationGenerated_type_info": [
			"QuotationGenerated",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"false"
		],
		"QuotationGenerated": true,
		"MotorPremium_type_info": [
			"MotorPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"MotorPremium": null,
		"LtiPremium_type_info": [
			"LtiPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"LtiPremium": null,
		"LgiPremium_type_info": [
			"LgiPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"LgiPremium": null,
		"IsiPremium_type_info": [
			"IsiPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"IsiPremium": null,
		"InsurerQuotationUrl_type_info": [
			"InsurerQuotationUrl",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"InsurerQuotationUrl": null,
		"GapPremium_type_info": [
			"GapPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"GapPremium": null,
		"field_order_type_info": [
			"CciPremium",
			"FailureReasons",
			"GapPremium",
			"InsurerQuotationUrl",
			"IsiPremium",
			"LgiPremium",
			"LtiPremium",
			"MotorPremium",
			"QuotationGenerated",
			"QuotationNumber",
			"ServiceContractPremium",
			"TotalAssistPremium",
			"TruckGapPremium",
			"VehicleDescription",
			"WarrantyPremium"
		],
		"FailureReasons_type_info": [
			"FailureReasons",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"FailureReasons": null,
		"CciPremium_type_info": [
			"CciPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"CciPremium": null,
		"apex_schema_type_info": [
			"http://services.fastr.com.au/Quotation/Data",
			"true",
			"false"
		]
	}
]
I am already able to pull values and transfer them to Apex objects for fields like QuotationNumber.

I am having some difficulty with parsing being attempted with items in the JSON like StampDuty. 

This is just returning a null value at the moment. 

I created this additional class to contain the value and used readValueAs to process the data into Apex.
public class TotalAssistPremium {
		//public List<String> StampDuty_type_info;
		public Double StampDuty;
		//public List<String> Premium_type_info;
		//public Integer Premium;
		//public List<String> Gst_type_info;
		//public Double Gst;
		//public List<String> field_order_type_info;
		//public List<String> EstablishmentFee_type_info;
		//public Integer EstablishmentFee;
		//public List<String> CoverTypeCode_type_info;
		//public String CoverTypeCode;
		//public List<String> CostExGst_type_info;
		//public Integer CostExGst;
		//public List<String> AvailablePaymentMethods_type_info;
		//public AvailablePaymentMethods AvailablePaymentMethods;
		//public List<String> apex_schema_type_info;
		
		public TotalAssistPremium(Double sTDty) {
		
		    StampDuty = sTDty;
		    
		}    
		
	}
This one is still nulling for me as I try to check on the StampDuty item from the JSON.
TotalAssistPremium tAsstPrem = (TotalAssistPremium)parser1.readValueAs(TotalAssistPremium.class);
Help on this is appreciated.
Hi,

I have 2 visualforce pages.

My first visualforce page is a pop-up page that has a command button. 

I want this button to be able to send data and trigger a rerender on my other visualforce page. 

Both of these visualforce pages are open at the same time, so I'm not sure about using page redirects.

Both visualforce pages are open at the same time, and when I click the command button or button in the first visualforce page, the other open visualforce page will rerender its output panel to show data coming from the first, the pop-up one.

Any ideas on implementing this?

Thanks in advance!

Best Regards,

Phil Fang | Developer
Hi all,

The code is working. Just to make it in Production, I need to do proper unit test to make sure the code coverage is above 75%.

In the Controller Extension, I made a simple Page Refence to save the record and it uses "update object.relatedObject__r" to save the related object. Later in the Unit Test, it returns the error saying "Attempt to de-reference a null object". The update line is controlled by condition that when object.relatedObject__c == null, the update line would never be reached.

Therefore, I am sure that the object.relatedObject__c is not null. Then, I thought maybe some fields in the relatedObject are null, which might cause this error. Then I put content in all the fields in the relatedObject. However, the system still returns the error "Attempt to de-reference a null object".

How do I solve this problem? Is there a way to test on the "Update object.relatedObject__r" code?

Thanks a lot.
Hi all,

The system has batch call out APEX classes to sync Salesforce information with another Email sending provider, Active Campaign. Every time we insert or update a custom lead or custom opportunity, the system will call out the batch classes to communicate with Active Campaign so we can send proper emails to our customers.

Everyday we have a plenty of records to change on Lead and Opportunity. Occasionally, the system reaches the 100 limit for Apex Flex Queue. Therefore, I modified the code when the 100 limit for Apex Flex Queue has been reached, new tasks will be scheduled in Scheduled Jobs. However, today both the Apex Flex Queue and the Scheduled jobs limit have been reached, which means at the backend Salesforce queued 200 tasks in the system.

I would like to know whether there are people who have experienced the same situation and how they solved this problem. I believe the code has been optimised to its maximum capacity, but if you want to see my code, please tell me. One of the reasons I do not put my code here is that there are four batch classes and three triggers to execute the whole process. There would be too much to put on the forum.

Thanks,
I have included jQuery as Static Resource and it is working with the Visualforce page when I include my own JavaScript code in <script type="text/javascript"> tag.

However, if I copy/paste the code into a .js file and upload it on static resource and include the file as apex:includeScript value, the JavaScript code never worked.

On the Visualforce page, I wrote jQuery.noConflict(); and use jQuery instead of '$' to make it work.

Later when I copied the original code into a .js file, I did not change anything. It did not work. Then I tried to use something like var j$ = jQuery.noConflict(); and replace all jQuery by j$. Not working. I also tried to delete the noConflict line and all using '$' as selector. Not working. Another try is to add (function($) {  }) (jQuery); to wrap the original code. Still not working.

Is there anything that I am mising to make the external js file which references jQuery working with the visualforce page?
There is a callout that needs batch class to execute. In the trigger, it will executed by

Database.executeBatch(new batchCallout(parameters),2000);

However, it occassionally reaches the 100 limit for "holding" status (Apex Flex Queue). Then to make it not reaching the limit, I did:

public static void scheduleBatch( parameters){
        batchCallout baltc = new batchCallout (parameters);
        system.scheduleBatch(baltc,'batchCallout', 30, 2000);
    }

in the batch class and in the trigger:

if ([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND (Status = 'Holding')] < 100){ 
                    Database.executeBatch(new batchCallout(parameters),2000);
                } else {
                    batchCallout.scheduleBatch(parameters);
                }

Therefore, when the limit is reached, the new tasks will be scheduled 30 minutes later.

However, in the reality, when people have changed the record of this object and the batch job is scheduled. The same record of the object cannot be changed again. Otherwise, the system will throw the exception:

trgAfterIU: execution of AfterUpdate

caused by: System.AsyncException: The Apex job named "batchCallout" is already scheduled for execution.


First of all, my explanation about it is that when the scheduled job is created, the same record cannot be changed until the scheduled job is done.
However, when the tasks was queued in Apex Flex queue, this kind of situation would never happen.
Therefore, I conclusion is that I should make the scheduled job to be in a queue. When a scheduled job is created, the next new scheduled job on the same record should be able to queue after that job to solve this problem.

My question is, how to queue the scheduled job so the collision I described above won't happen again?
Hi All,

I followed the instruction on the S-Docs documentation wrting something like 

SDOC.SDBatch.createSDoc(UserInfo.getSessionId(),'id='+opp.id+'&Object=Custom_Opportunity__c&doclist=a07N0000006LbCU');

However, in my testing, the documents had never been generated.

I had a look at Apex job, it says something like

26/11/2015 4:35 PM Future Completed   0 0 0 Username 26/11/2015 4:35 PM SDBatch createSDoc 707N000000MAd2n

Do not know why it is future method and although it is completed, 0 batch was executed.

I had a try on 

SDOC.SDBatch.createSDoc('',username,'id='+opp.id+'&Object=Custom_Opportunity__c&doclist=a07N0000006LbCU');

which is mentioned on the SDocs document. However, the system says there isn't a method can accept creatSDoc(string, string, string).

Is there anyone that are famliar with SDocs?

Thanks
Hi,

I have the following JSON retrieved from a web service request. 
[
	{
		"WarrantyPremium_type_info": [
			"WarrantyPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"WarrantyPremium": null,
		"VehicleDescription_type_info": [
			"VehicleDescription",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"VehicleDescription": null,
		"TruckGapPremium_type_info": [
			"TruckGapPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"TruckGapPremium": null,
		"TotalAssistPremium_type_info": [
			"TotalAssistPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"TotalAssistPremium": {
			"StampDuty_type_info": [
				"StampDuty",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"false"
			],
			"StampDuty": 112.27,
			"Premium_type_info": [
				"Premium",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"false"
			],
			"Premium": 1235,
			"Gst_type_info": [
				"Gst",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"false"
			],
			"Gst": 102.07,
			"field_order_type_info": [
				"AvailablePaymentMethods",
				"CostExGst",
				"CoverTypeCode",
				"EstablishmentFee",
				"Gst",
				"Premium",
				"StampDuty"
			],
			"EstablishmentFee_type_info": [
				"EstablishmentFee",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"false"
			],
			"EstablishmentFee": 44,
			"CoverTypeCode_type_info": [
				"CoverTypeCode",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"0",
				"1",
				"true"
			],
			"CoverTypeCode": "TC1",
			"CostExGst_type_info": [
				"CostExGst",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"true"
			],
			"CostExGst": 500,
			"AvailablePaymentMethods_type_info": [
				"AvailablePaymentMethods",
				"http://services.fastr.com.au/Quotation/Data",
				null,
				"1",
				"1",
				"true"
			],
			"AvailablePaymentMethods": {
				"PaymentMethod_type_info": [
					"PaymentMethod",
					"http://services.fastr.com.au/Quotation/Data",
					null,
					"0",
					"-1",
					"true"
				],
				"PaymentMethod": [
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1279,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": null,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Full - Credit Card",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": null,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "CREDITCARD",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					},
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1279,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": null,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Full - Dealer Cheque",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": null,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "DEALERCHEQUE",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					},
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1279,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": null,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Full - Finance Company",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": null,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "FINANCECOMPANY",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					},
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1383.2,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": 12,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Monthly - Bank account",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": 115.27,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "PREMFUND12BA",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					},
					{
						"Payable_type_info": [
							"Payable",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"false"
						],
						"Payable": 1383.2,
						"NumberOfInstalments_type_info": [
							"NumberOfInstalments",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"NumberOfInstalments": 12,
						"Name_type_info": [
							"Name",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Name": "Monthly - Credit Card",
						"InstalmentAmount_type_info": [
							"InstalmentAmount",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"0",
							"1",
							"true"
						],
						"InstalmentAmount": 115.27,
						"field_order_type_info": [
							"Code",
							"InstalmentAmount",
							"Name",
							"NumberOfInstalments",
							"Payable"
						],
						"Code_type_info": [
							"Code",
							"http://services.fastr.com.au/Quotation/Data",
							null,
							"1",
							"1",
							"true"
						],
						"Code": "PREMFUND12CC",
						"apex_schema_type_info": [
							"http://services.fastr.com.au/Quotation/Data",
							"true",
							"false"
						]
					}
				],
				"field_order_type_info": [
					"PaymentMethod"
				],
				"apex_schema_type_info": [
					"http://services.fastr.com.au/Quotation/Data",
					"true",
					"false"
				]
			},
			"apex_schema_type_info": [
				"http://services.fastr.com.au/Quotation/Data",
				"true",
				"false"
			]
		},
		"ServiceContractPremium_type_info": [
			"ServiceContractPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"ServiceContractPremium": null,
		"QuotationNumber_type_info": [
			"QuotationNumber",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"QuotationNumber": "Q14327612",
		"QuotationGenerated_type_info": [
			"QuotationGenerated",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"false"
		],
		"QuotationGenerated": true,
		"MotorPremium_type_info": [
			"MotorPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"MotorPremium": null,
		"LtiPremium_type_info": [
			"LtiPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"LtiPremium": null,
		"LgiPremium_type_info": [
			"LgiPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"LgiPremium": null,
		"IsiPremium_type_info": [
			"IsiPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"IsiPremium": null,
		"InsurerQuotationUrl_type_info": [
			"InsurerQuotationUrl",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"InsurerQuotationUrl": null,
		"GapPremium_type_info": [
			"GapPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"GapPremium": null,
		"field_order_type_info": [
			"CciPremium",
			"FailureReasons",
			"GapPremium",
			"InsurerQuotationUrl",
			"IsiPremium",
			"LgiPremium",
			"LtiPremium",
			"MotorPremium",
			"QuotationGenerated",
			"QuotationNumber",
			"ServiceContractPremium",
			"TotalAssistPremium",
			"TruckGapPremium",
			"VehicleDescription",
			"WarrantyPremium"
		],
		"FailureReasons_type_info": [
			"FailureReasons",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"FailureReasons": null,
		"CciPremium_type_info": [
			"CciPremium",
			"http://services.fastr.com.au/Quotation/Data",
			null,
			"0",
			"1",
			"true"
		],
		"CciPremium": null,
		"apex_schema_type_info": [
			"http://services.fastr.com.au/Quotation/Data",
			"true",
			"false"
		]
	}
]
I am already able to pull values and transfer them to Apex objects for fields like QuotationNumber.

I am having some difficulty with parsing being attempted with items in the JSON like StampDuty. 

This is just returning a null value at the moment. 

I created this additional class to contain the value and used readValueAs to process the data into Apex.
public class TotalAssistPremium {
		//public List<String> StampDuty_type_info;
		public Double StampDuty;
		//public List<String> Premium_type_info;
		//public Integer Premium;
		//public List<String> Gst_type_info;
		//public Double Gst;
		//public List<String> field_order_type_info;
		//public List<String> EstablishmentFee_type_info;
		//public Integer EstablishmentFee;
		//public List<String> CoverTypeCode_type_info;
		//public String CoverTypeCode;
		//public List<String> CostExGst_type_info;
		//public Integer CostExGst;
		//public List<String> AvailablePaymentMethods_type_info;
		//public AvailablePaymentMethods AvailablePaymentMethods;
		//public List<String> apex_schema_type_info;
		
		public TotalAssistPremium(Double sTDty) {
		
		    StampDuty = sTDty;
		    
		}    
		
	}
This one is still nulling for me as I try to check on the StampDuty item from the JSON.
TotalAssistPremium tAsstPrem = (TotalAssistPremium)parser1.readValueAs(TotalAssistPremium.class);
Help on this is appreciated.
Hi,

I have 2 visualforce pages.

My first visualforce page is a pop-up page that has a command button. 

I want this button to be able to send data and trigger a rerender on my other visualforce page. 

Both of these visualforce pages are open at the same time, so I'm not sure about using page redirects.

Both visualforce pages are open at the same time, and when I click the command button or button in the first visualforce page, the other open visualforce page will rerender its output panel to show data coming from the first, the pop-up one.

Any ideas on implementing this?

Thanks in advance!

Best Regards,

Phil Fang | Developer
Hi all,

The code is working. Just to make it in Production, I need to do proper unit test to make sure the code coverage is above 75%.

In the Controller Extension, I made a simple Page Refence to save the record and it uses "update object.relatedObject__r" to save the related object. Later in the Unit Test, it returns the error saying "Attempt to de-reference a null object". The update line is controlled by condition that when object.relatedObject__c == null, the update line would never be reached.

Therefore, I am sure that the object.relatedObject__c is not null. Then, I thought maybe some fields in the relatedObject are null, which might cause this error. Then I put content in all the fields in the relatedObject. However, the system still returns the error "Attempt to de-reference a null object".

How do I solve this problem? Is there a way to test on the "Update object.relatedObject__r" code?

Thanks a lot.
Hi all,

The system has batch call out APEX classes to sync Salesforce information with another Email sending provider, Active Campaign. Every time we insert or update a custom lead or custom opportunity, the system will call out the batch classes to communicate with Active Campaign so we can send proper emails to our customers.

Everyday we have a plenty of records to change on Lead and Opportunity. Occasionally, the system reaches the 100 limit for Apex Flex Queue. Therefore, I modified the code when the 100 limit for Apex Flex Queue has been reached, new tasks will be scheduled in Scheduled Jobs. However, today both the Apex Flex Queue and the Scheduled jobs limit have been reached, which means at the backend Salesforce queued 200 tasks in the system.

I would like to know whether there are people who have experienced the same situation and how they solved this problem. I believe the code has been optimised to its maximum capacity, but if you want to see my code, please tell me. One of the reasons I do not put my code here is that there are four batch classes and three triggers to execute the whole process. There would be too much to put on the forum.

Thanks,
I have included jQuery as Static Resource and it is working with the Visualforce page when I include my own JavaScript code in <script type="text/javascript"> tag.

However, if I copy/paste the code into a .js file and upload it on static resource and include the file as apex:includeScript value, the JavaScript code never worked.

On the Visualforce page, I wrote jQuery.noConflict(); and use jQuery instead of '$' to make it work.

Later when I copied the original code into a .js file, I did not change anything. It did not work. Then I tried to use something like var j$ = jQuery.noConflict(); and replace all jQuery by j$. Not working. I also tried to delete the noConflict line and all using '$' as selector. Not working. Another try is to add (function($) {  }) (jQuery); to wrap the original code. Still not working.

Is there anything that I am mising to make the external js file which references jQuery working with the visualforce page?
There is a callout that needs batch class to execute. In the trigger, it will executed by

Database.executeBatch(new batchCallout(parameters),2000);

However, it occassionally reaches the 100 limit for "holding" status (Apex Flex Queue). Then to make it not reaching the limit, I did:

public static void scheduleBatch( parameters){
        batchCallout baltc = new batchCallout (parameters);
        system.scheduleBatch(baltc,'batchCallout', 30, 2000);
    }

in the batch class and in the trigger:

if ([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND (Status = 'Holding')] < 100){ 
                    Database.executeBatch(new batchCallout(parameters),2000);
                } else {
                    batchCallout.scheduleBatch(parameters);
                }

Therefore, when the limit is reached, the new tasks will be scheduled 30 minutes later.

However, in the reality, when people have changed the record of this object and the batch job is scheduled. The same record of the object cannot be changed again. Otherwise, the system will throw the exception:

trgAfterIU: execution of AfterUpdate

caused by: System.AsyncException: The Apex job named "batchCallout" is already scheduled for execution.


First of all, my explanation about it is that when the scheduled job is created, the same record cannot be changed until the scheduled job is done.
However, when the tasks was queued in Apex Flex queue, this kind of situation would never happen.
Therefore, I conclusion is that I should make the scheduled job to be in a queue. When a scheduled job is created, the next new scheduled job on the same record should be able to queue after that job to solve this problem.

My question is, how to queue the scheduled job so the collision I described above won't happen again?
Hi All,

I followed the instruction on the S-Docs documentation wrting something like 

SDOC.SDBatch.createSDoc(UserInfo.getSessionId(),'id='+opp.id+'&Object=Custom_Opportunity__c&doclist=a07N0000006LbCU');

However, in my testing, the documents had never been generated.

I had a look at Apex job, it says something like

26/11/2015 4:35 PM Future Completed   0 0 0 Username 26/11/2015 4:35 PM SDBatch createSDoc 707N000000MAd2n

Do not know why it is future method and although it is completed, 0 batch was executed.

I had a try on 

SDOC.SDBatch.createSDoc('',username,'id='+opp.id+'&Object=Custom_Opportunity__c&doclist=a07N0000006LbCU');

which is mentioned on the SDocs document. However, the system says there isn't a method can accept creatSDoc(string, string, string).

Is there anyone that are famliar with SDocs?

Thanks