-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
10Questions
-
8Replies
is it possible to use wild card certificate in salesforce
Hi Team,
I am creating CA certificate for the particular site in Salesforce. I want to create "Wild Card " certificate. Can i use common name as wild card name ?
I am creating CA certificate for the particular site in Salesforce. I want to create "Wild Card " certificate. Can i use common name as wild card name ?
- Vinothini murugesh 10
- July 01, 2019
- Like
- 0
I am getting Not secure option fro the URL which i am using. Could any body help me to overcome this issue
I am getting Not secure option fro the URL which i am using. Could any body help me to overcome this issue
Hi All,
I am getting "Not Secure " warning while using www.dcfarmconnect.co.uk the URL. Kinldy help me on this issue.
Hi All,
I am getting "Not Secure " warning while using www.dcfarmconnect.co.uk the URL. Kinldy help me on this issue.
- Vinothini murugesh 10
- February 21, 2019
- Like
- 0
System.XmlException: Failed to parse XML due to: only whitespace content allowed before start tag and not { (position: START_DOCUMENT seen {... @1:1)
Getting test class error:
handler class:
public class IRIS_Contact_Campaign_Handler {
public static boolean recursiveFlagCheck = false;
// Defining the End Points of Marketing Cloud URL
Static String MARKETING_CLOUD_AUTH_URL = 'https://auth.exacttargetapis.com/v1/requestToken';
Static String ACCESS_TOKEN = 'accessToken';
Static String MARKETING_CLOUD_ENDPOINT = 'https://webservice.s6.exacttarget.com/Service.asmx';
// API Name of the Data Extension
String DEAPIName = 'IRIS_Campaign_Email_Results_XREF';
public IRIS_Contact_Campaign_Handler(){
ACCESS_TOKEN = getMarketingCloudOAuthToken('abc', 'abc');
performMCAction(ACCESS_TOKEN, DEAPIName);
}
public static String makeSimpleJSONPostCall(String endPoint, String soapBody){
Http h = new Http();
HttpRequest r = new HttpRequest();
r.setTimeout(60000);
r.setEndpoint(endPoint);
r.setMethod('POST');
r.setHeader('Content-type','application/json');
r.setBody(soapBody);
HttpResponse res = h.send(r);
System.Debug('makeSimpleJSONPostCall response: ' + res.getBody());
//performMCAction(res.getBody().accessToken,DEAPIName);
system.debug('Json values' + res.getBody());
return res.getBody();
}
public static String makeHTTPXMLPost(String endPoint, String soapBody, String SOAPAction){
Http h = new Http();
HttpRequest r = new HttpRequest();
r.setTimeout(60000);
r.setEndpoint(endPoint);
r.setMethod('POST');
r.setHeader('SOAPAction',SOAPAction);
r.setHeader('Accept','text/xml');
r.setHeader('Content-type','text/xml');
r.setHeader('charset','UTF-8');
r.setBody(soapBody);
HttpResponse s = h.send(r);
system.debug('Testing ' +s.getBody());
DOM.Document doc = new DOM.Document();
String toParse = s.getBody();
doc.load(toParse);
DOM.XMLNode root = doc.getRootElement();
String nms = root.getNameSpace();
List<IRIS_Contact_Campaign__c> concompans = New List<IRIS_Contact_Campaign__c>();
system.debug('namespace--'+nms);
DOM.XMLNode body = root.getChildElement('Body', nms);
System.Debug('body: ' + body);
List<DOM.XMLNode> bodyChildrenList = body.getChildElements();
for (DOM.XMLNode passThroughReqResponse : bodyChildrenList) {
//System.Debug('passThroughReqResponse: ' + passThroughReqResponse.getName());
List<DOM.XMLNode> passThroughReqResultList = passThroughReqResponse.getChildElements();
for (DOM.XMLNode passThroughReqResult : passThroughReqResultList){
// System.Debug('passThroughReqResult: ' + passThroughReqResult.getName());
List<DOM.XMLNode> pickResponseList = passThroughReqResult.getChildElements();
for (DOM.XMLNode pickResponse : pickResponseList) {
//System.Debug('pickResponse: ' + pickResponse.getName());
List<DOM.XMLNode> filesList = pickResponse.getChildElements();
system.debug('Length ' + filesList.size());
if(filesList.size() != 0) {
IRIS_Contact_Campaign__c concmp = new IRIS_Contact_Campaign__c();
List<DOM.XMLNode> f1 = filesList[0].getChildElements();
List<DOM.XMLNode> f2 = filesList[1].getChildElements();
List<DOM.XMLNode> f3 = filesList[2].getChildElements();
List<DOM.XMLNode> f4 = filesList[3].getChildElements();
concmp.Campaign_ID__c = f1[1].getText();
concmp.Contact_ID__c = f2[1].getText();
concmp.Email_Subject__c = f3[1].getText();
concmp.Job_ID__c = f4[1].getText();
concompans.add(concmp);
}
}
}
}
if (concompans.size() != 0){
system.debug('Marketing Values ' + concompans);
if(!recursiveFlagCheck){
insert concompans;
recursiveFlagCheck = true;
}
}
return s.getBody();
}
public static String getMarketingCloudOAuthToken(String clientId, String clientSecret){
Marketing_Cloud_Credentials__c mcCredentials = Marketing_Cloud_Credentials__c.getValues('Marketing Cloud Credentials');
String cId = mcCredentials.Client_Id__c;
String cSecret = mcCredentials.Client_Secret__c;
String responseBody = makeSimpleJSONPostCall(
MARKETING_CLOUD_AUTH_URL,
JSON.serialize( new Map<String, String>{
'clientId' => cId,
'clientSecret' => cSecret
} )
);
string returnS = ((Map<String, String>) JSON.deserialize(responseBody, Map<String, String>.class)).get( ACCESS_TOKEN );
System.debug('getMarketingCloudOAuthToken return value = ' + returnS);
return returnS;
}
public static String performMCAction(String accessToken, String DEAPIName){
String soapEnvelopeTemplate = '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
' <Header>'+
' <fueloauth>{0}</fueloauth>'+
' </Header>'+
' <Body>'+
'<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">'+
'<RetrieveRequest>'+
'<ClientIDs>'+
'<ID>6422194</ID>'+
'</ClientIDs>'+
'<ObjectType>DataExtensionObject[IRIS_Campaign_Email_Results_XREF]</ObjectType>'+
'<Properties>IRIS_Campaign_ID</Properties>'+
'<Properties>Contact_ID</Properties>'+
'<Properties>Email_Subject</Properties>'+
'<Properties>ID</Properties>'+
'</RetrieveRequest>'+
'</RetrieveRequestMsg>'+
'</Body>'+
' </Envelope>';
System.debug('testting' + accessToken);
String body = String.format(soapEnvelopeTemplate, new String[]{accessToken, DEAPIName});
return makeHTTPXMLPost( MARKETING_CLOUD_ENDPOINT , body, 'Retrieve' );
}
}
Test class:
@isTest
public class Iris_contact_campaign_handler_test {
Static testmethod void test1(){
// IRIS_Contact_Campaign_Handler c=new IRIS_Contact_Campaign_Handler();
Marketing_Cloud_Credentials__c c=new Marketing_Cloud_Credentials__c();
c.Client_Id__c='sdqpej9i0k3pj9j9tl4jpwfq';
c.Client_Secret__c='nJYBnltT3N94f96cNtfcOhO3';
c.name='Marketing Cloud Credentials';
insert c;
test.startTest();
Test.setMock(HttpCalloutMock.class, new YourWebServiceMock());
IRIS_Contact_Campaign_Handler c1=new IRIS_Contact_Campaign_Handler();
test.stopTest();
}
}
Mock impl:
@isTest
global class YourWebServiceMock implements HttpCalloutMock {
global HTTPResponse respond(HTTPRequest req) {
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'application/Json');
res.setBody('{"foo":"bar"}');
res.setStatusCode(200);
return res;
}
}
Please help on this
handler class:
public class IRIS_Contact_Campaign_Handler {
public static boolean recursiveFlagCheck = false;
// Defining the End Points of Marketing Cloud URL
Static String MARKETING_CLOUD_AUTH_URL = 'https://auth.exacttargetapis.com/v1/requestToken';
Static String ACCESS_TOKEN = 'accessToken';
Static String MARKETING_CLOUD_ENDPOINT = 'https://webservice.s6.exacttarget.com/Service.asmx';
// API Name of the Data Extension
String DEAPIName = 'IRIS_Campaign_Email_Results_XREF';
public IRIS_Contact_Campaign_Handler(){
ACCESS_TOKEN = getMarketingCloudOAuthToken('abc', 'abc');
performMCAction(ACCESS_TOKEN, DEAPIName);
}
public static String makeSimpleJSONPostCall(String endPoint, String soapBody){
Http h = new Http();
HttpRequest r = new HttpRequest();
r.setTimeout(60000);
r.setEndpoint(endPoint);
r.setMethod('POST');
r.setHeader('Content-type','application/json');
r.setBody(soapBody);
HttpResponse res = h.send(r);
System.Debug('makeSimpleJSONPostCall response: ' + res.getBody());
//performMCAction(res.getBody().accessToken,DEAPIName);
system.debug('Json values' + res.getBody());
return res.getBody();
}
public static String makeHTTPXMLPost(String endPoint, String soapBody, String SOAPAction){
Http h = new Http();
HttpRequest r = new HttpRequest();
r.setTimeout(60000);
r.setEndpoint(endPoint);
r.setMethod('POST');
r.setHeader('SOAPAction',SOAPAction);
r.setHeader('Accept','text/xml');
r.setHeader('Content-type','text/xml');
r.setHeader('charset','UTF-8');
r.setBody(soapBody);
HttpResponse s = h.send(r);
system.debug('Testing ' +s.getBody());
DOM.Document doc = new DOM.Document();
String toParse = s.getBody();
doc.load(toParse);
DOM.XMLNode root = doc.getRootElement();
String nms = root.getNameSpace();
List<IRIS_Contact_Campaign__c> concompans = New List<IRIS_Contact_Campaign__c>();
system.debug('namespace--'+nms);
DOM.XMLNode body = root.getChildElement('Body', nms);
System.Debug('body: ' + body);
List<DOM.XMLNode> bodyChildrenList = body.getChildElements();
for (DOM.XMLNode passThroughReqResponse : bodyChildrenList) {
//System.Debug('passThroughReqResponse: ' + passThroughReqResponse.getName());
List<DOM.XMLNode> passThroughReqResultList = passThroughReqResponse.getChildElements();
for (DOM.XMLNode passThroughReqResult : passThroughReqResultList){
// System.Debug('passThroughReqResult: ' + passThroughReqResult.getName());
List<DOM.XMLNode> pickResponseList = passThroughReqResult.getChildElements();
for (DOM.XMLNode pickResponse : pickResponseList) {
//System.Debug('pickResponse: ' + pickResponse.getName());
List<DOM.XMLNode> filesList = pickResponse.getChildElements();
system.debug('Length ' + filesList.size());
if(filesList.size() != 0) {
IRIS_Contact_Campaign__c concmp = new IRIS_Contact_Campaign__c();
List<DOM.XMLNode> f1 = filesList[0].getChildElements();
List<DOM.XMLNode> f2 = filesList[1].getChildElements();
List<DOM.XMLNode> f3 = filesList[2].getChildElements();
List<DOM.XMLNode> f4 = filesList[3].getChildElements();
concmp.Campaign_ID__c = f1[1].getText();
concmp.Contact_ID__c = f2[1].getText();
concmp.Email_Subject__c = f3[1].getText();
concmp.Job_ID__c = f4[1].getText();
concompans.add(concmp);
}
}
}
}
if (concompans.size() != 0){
system.debug('Marketing Values ' + concompans);
if(!recursiveFlagCheck){
insert concompans;
recursiveFlagCheck = true;
}
}
return s.getBody();
}
public static String getMarketingCloudOAuthToken(String clientId, String clientSecret){
Marketing_Cloud_Credentials__c mcCredentials = Marketing_Cloud_Credentials__c.getValues('Marketing Cloud Credentials');
String cId = mcCredentials.Client_Id__c;
String cSecret = mcCredentials.Client_Secret__c;
String responseBody = makeSimpleJSONPostCall(
MARKETING_CLOUD_AUTH_URL,
JSON.serialize( new Map<String, String>{
'clientId' => cId,
'clientSecret' => cSecret
} )
);
string returnS = ((Map<String, String>) JSON.deserialize(responseBody, Map<String, String>.class)).get( ACCESS_TOKEN );
System.debug('getMarketingCloudOAuthToken return value = ' + returnS);
return returnS;
}
public static String performMCAction(String accessToken, String DEAPIName){
String soapEnvelopeTemplate = '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'+
' <Header>'+
' <fueloauth>{0}</fueloauth>'+
' </Header>'+
' <Body>'+
'<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">'+
'<RetrieveRequest>'+
'<ClientIDs>'+
'<ID>6422194</ID>'+
'</ClientIDs>'+
'<ObjectType>DataExtensionObject[IRIS_Campaign_Email_Results_XREF]</ObjectType>'+
'<Properties>IRIS_Campaign_ID</Properties>'+
'<Properties>Contact_ID</Properties>'+
'<Properties>Email_Subject</Properties>'+
'<Properties>ID</Properties>'+
'</RetrieveRequest>'+
'</RetrieveRequestMsg>'+
'</Body>'+
' </Envelope>';
System.debug('testting' + accessToken);
String body = String.format(soapEnvelopeTemplate, new String[]{accessToken, DEAPIName});
return makeHTTPXMLPost( MARKETING_CLOUD_ENDPOINT , body, 'Retrieve' );
}
}
Test class:
@isTest
public class Iris_contact_campaign_handler_test {
Static testmethod void test1(){
// IRIS_Contact_Campaign_Handler c=new IRIS_Contact_Campaign_Handler();
Marketing_Cloud_Credentials__c c=new Marketing_Cloud_Credentials__c();
c.Client_Id__c='sdqpej9i0k3pj9j9tl4jpwfq';
c.Client_Secret__c='nJYBnltT3N94f96cNtfcOhO3';
c.name='Marketing Cloud Credentials';
insert c;
test.startTest();
Test.setMock(HttpCalloutMock.class, new YourWebServiceMock());
IRIS_Contact_Campaign_Handler c1=new IRIS_Contact_Campaign_Handler();
test.stopTest();
}
}
Mock impl:
@isTest
global class YourWebServiceMock implements HttpCalloutMock {
global HTTPResponse respond(HTTPRequest req) {
HttpResponse res = new HttpResponse();
res.setHeader('Content-Type', 'application/Json');
res.setBody('{"foo":"bar"}');
res.setStatusCode(200);
return res;
}
}
Please help on this
- Vinothini murugesh 10
- May 08, 2018
- Like
- 0
i am getting view state error when i choose no.of records to 50 in my vf page.showing size is more than 135 kb.i have used Transient keyword and checked. still i m getting the error
<apex:page controller="RTV_ApprovalController" id="pageid" tabstyle="RTV_Approvals__tab">
<script>
function cvCheckAllOrNone(allOrNoneCheckbox) {
// Find parent table
var container = allOrNoneCheckbox;
while (container.tagName != "TABLE") {
container = container.parentNode;
}
// Switch all checkboxes
var inputs = container.getElementsByTagName("input");
var checked = allOrNoneCheckbox.checked;
for (var i = 0; i < inputs.length; i++) {
var input = inputs.item(i);
if (input.type == "checkbox") {
if (input != allOrNoneCheckbox) {
input.checked = checked;
}
}
}
}
</script>
<!-- Define Tab panel .css styles -->
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/versioning.css" />
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/extended.css" />
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/>
<script type="text/javascript">
j$ = jQuery.noConflict();
function showLoadingDiv() {
var newHeight = j$("[id$=pblkIds]").css("height");//Just shade the body, not the header
j$("[id$=loading-curtain-div]").css("background-color", "black").css("opacity", 0.35).css("height", newHeight).css("width", "80%");
}
function hideLoadingDiv() {
j$("[id$=loading-curtain-div]").css("background-color", "black").css("opacity", "1").css("height", "0px").css("width", "80%");
}
function getSelectedTabName() {
if (RichFaces) {
var tabs = RichFaces.panelTabs['pageid:form:tabpanel'];
for (var i = 0; i < tabs.length; i++) {
var tab = tabs[i];
if (RichFaces.isTabActive(tab.id + '_lbl')) {
return tab.name;
}
}
}
return null;
}
function setSelectedTabOnController() {
selectTabActionFunction(getSelectedTabName());
}
function select1(){
sel2();
}
function select2(){
sel2();
}
</script>
<style>
.activeTab {background-color: #236FBD; color:white; background-image:none}
.inactiveTab { background-color: black; color:black; background-image:none}
#loading-curtain-div {
height:0px;
width:100%;
position:absolute;
z-index:5;
-webkit-transition: all 0.30s ease-out;
-moz-transition: all 0.30s ease-out;
}
.no-js #loader { display: none; }
.js #loader { display: block; position: absolute; left: 100px; top: 0; }
.se-pre-con {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: URLFOR($Resource.preloader,'simple-pre-loader\images\loader-32x\loader1.gif') center no-repeat #fff;
}
</style>
<apex:tabPanel switchType="client" styleClass="theTabPanel" tabClass="theTabPanel" contentClass="tabContent" activeTabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="name1" id="tabpanel" >
<apex:tab label="RTV - To Submit for Approval" name="name1" reRender="pbIds" id="tabOne" style="bachground-blend-mode:color-burn; background-color:white">
<div id="loading-curtain-div"/>
<apex:form id="form" >
<apex:outputPanel id="pnlId" layout="none" >
<apex:pageBlock title="RTV - To Submit for Approval" id="pblkIds" >
<b>Select Region</b>
<apex:selectList value="{!selectedRegion}" size="1" title="Select Region" label="Select Region">
<apex:actionSupport event="onchange" action="{!getrefreshGrid}" status="statusMsg" reRender="pblkIds,pbIds"/>
<apex:selectOptions value="{!lstSelectOptions}"/>
</apex:selectList>
<b>No. of records per page:</b>
<apex:selectList value="{!pageSize}" size="1" title=" No. of records per page" label="No. of records per page">
<apex:actionSupport event="onchange" action="{!getrefreshGrid}" status="statusMsg" reRender="pblkIds,pbIds"/>
<apex:selectOption itemLabel="10" itemValue="10" />
<apex:selectOption itemLabel="20" itemValue="20" />
<apex:selectOption itemLabel="50" itemValue="50" />
<apex:selectOption itemLabel="100" itemValue="100" />
</apex:selectList><br/><br/>
<b> Filter Text</b>
<apex:inputText value="{!searchText}" />
<apex:commandButton value="Filter" action="{!search}" reRender="pnlId" >
</apex:commandButton>
<I>*Please use Refresh button to reset the filter applied. </I><br/>
<apex:pageBlockSection title="RTV - To be submitted for Approval" collapsible="false" id="sect" columns="1">
<apex:outputPanel layout="none" style="overflow:auto;height:380px" id="iddf" >
<apex:pageMessages id="ff" />
<apex:pageBlockTable value="{!lstSetController}" var="obj" Id="pbtblids">
<apex:column >
<apex:facet name="header">
<apex:outputText > Action</apex:outputText>
<apex:inputCheckbox label="Action" onclick="cvCheckAllOrNone(this)" title="Toggle All Rows"/>
</apex:facet>
<apex:inputCheckbox value="{!obj.isSelected}"/>
</apex:column>
<apex:repeat value="{!$ObjectType.Return_To_Vendor__c.FieldSets.RTVApprovalFieldSet}" var="f">
<apex:column >
<apex:variable value="{!SUBSTITUTE(f.fieldPath,'__c', '__r.Name')}" var="Name" rendered="{!if(f.type=='reference',true,false)}"/>
<apex:outputLink value="/{!obj.rtv[f]}" rendered="{!if(f.type=='reference', true, false)}" > {!obj.rtv[Name]}</apex:outputLink>
<apex:outputLink value="/{!obj.rtv['Id']}" rendered="{!if(f.FieldPath=='Name', true, false)}" > {!obj.rtv[f]}</apex:outputLink>
<!--<apex:outputtext value="{!obj.rtv[f]}" rendered="{!if(f.type=='reference' || f.FieldPath=='Name', false, true)}" />-->
<apex:outputField value="{!obj.rtv[f]}" rendered="{!if(f.type=='reference' || f.FieldPath=='Name', false, true)}" />
<apex:facet name="header">
<apex:commandLink value="{!f.Label}" status="statusMsg" action="{!sort}" reRender="pnlId">
<apex:param name="{!f.fieldPath}" assignTo="{!field}" value="{!f.FieldPath}"/>
<apex:param name="{!f.fieldPath+f.type}" assignTo="{!fieldType}" value="{!f.type}"/>
</apex:commandLink>
</apex:facet>
</apex:column>
<apex:outputText value="{!obj.rtv[f]}" /><br/>
</apex:repeat>
</apex:pageBlockTable>
<apex:commandButton value="<<Previous" action="{!previous}" status="statusMsg" rendered="{!hasPrevious}" reRender="pnlId" />
<apex:commandButton value="Next >>" action="{!next}" status="statusMsg" rendered="{!hasNext}" reRender="pnlId" />
</apex:outputPanel>
</apex:pageBlockSection>
<apex:pageBlockButtons location="top">
<apex:actionStatus onstart="showLoadingDiv();" onstop="hideLoadingDiv();" id="statusMsg">
<apex:facet name="start" >
<img src="/img/loading.gif" />
</apex:facet>
</apex:actionStatus>
<apex:commandButton action="{!SubmitForApproval}" value="Submit for Approval" status="statusMsg" reRender="pnlId,statusMsg "/>
<apex:commandButton action="{!refresh}" status="statusMsg" value="Refresh" rerender="pnlId"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:tab>
<apex:tab label="Items to Approve" name="name2" style="bachground-blend-mode:color-burn; background-color:white">
<apex:iframe src="/apex/RTV_My_Pending_Approvals" scrolling="true" id="theIframe" />
</apex:tab>
</apex:tabpanel>
</apex:page>
<script>
function cvCheckAllOrNone(allOrNoneCheckbox) {
// Find parent table
var container = allOrNoneCheckbox;
while (container.tagName != "TABLE") {
container = container.parentNode;
}
// Switch all checkboxes
var inputs = container.getElementsByTagName("input");
var checked = allOrNoneCheckbox.checked;
for (var i = 0; i < inputs.length; i++) {
var input = inputs.item(i);
if (input.type == "checkbox") {
if (input != allOrNoneCheckbox) {
input.checked = checked;
}
}
}
}
</script>
<!-- Define Tab panel .css styles -->
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/versioning.css" />
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/extended.css" />
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/>
<script type="text/javascript">
j$ = jQuery.noConflict();
function showLoadingDiv() {
var newHeight = j$("[id$=pblkIds]").css("height");//Just shade the body, not the header
j$("[id$=loading-curtain-div]").css("background-color", "black").css("opacity", 0.35).css("height", newHeight).css("width", "80%");
}
function hideLoadingDiv() {
j$("[id$=loading-curtain-div]").css("background-color", "black").css("opacity", "1").css("height", "0px").css("width", "80%");
}
function getSelectedTabName() {
if (RichFaces) {
var tabs = RichFaces.panelTabs['pageid:form:tabpanel'];
for (var i = 0; i < tabs.length; i++) {
var tab = tabs[i];
if (RichFaces.isTabActive(tab.id + '_lbl')) {
return tab.name;
}
}
}
return null;
}
function setSelectedTabOnController() {
selectTabActionFunction(getSelectedTabName());
}
function select1(){
sel2();
}
function select2(){
sel2();
}
</script>
<style>
.activeTab {background-color: #236FBD; color:white; background-image:none}
.inactiveTab { background-color: black; color:black; background-image:none}
#loading-curtain-div {
height:0px;
width:100%;
position:absolute;
z-index:5;
-webkit-transition: all 0.30s ease-out;
-moz-transition: all 0.30s ease-out;
}
.no-js #loader { display: none; }
.js #loader { display: block; position: absolute; left: 100px; top: 0; }
.se-pre-con {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: URLFOR($Resource.preloader,'simple-pre-loader\images\loader-32x\loader1.gif') center no-repeat #fff;
}
</style>
<apex:tabPanel switchType="client" styleClass="theTabPanel" tabClass="theTabPanel" contentClass="tabContent" activeTabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="name1" id="tabpanel" >
<apex:tab label="RTV - To Submit for Approval" name="name1" reRender="pbIds" id="tabOne" style="bachground-blend-mode:color-burn; background-color:white">
<div id="loading-curtain-div"/>
<apex:form id="form" >
<apex:outputPanel id="pnlId" layout="none" >
<apex:pageBlock title="RTV - To Submit for Approval" id="pblkIds" >
<b>Select Region</b>
<apex:selectList value="{!selectedRegion}" size="1" title="Select Region" label="Select Region">
<apex:actionSupport event="onchange" action="{!getrefreshGrid}" status="statusMsg" reRender="pblkIds,pbIds"/>
<apex:selectOptions value="{!lstSelectOptions}"/>
</apex:selectList>
<b>No. of records per page:</b>
<apex:selectList value="{!pageSize}" size="1" title=" No. of records per page" label="No. of records per page">
<apex:actionSupport event="onchange" action="{!getrefreshGrid}" status="statusMsg" reRender="pblkIds,pbIds"/>
<apex:selectOption itemLabel="10" itemValue="10" />
<apex:selectOption itemLabel="20" itemValue="20" />
<apex:selectOption itemLabel="50" itemValue="50" />
<apex:selectOption itemLabel="100" itemValue="100" />
</apex:selectList><br/><br/>
<b> Filter Text</b>
<apex:inputText value="{!searchText}" />
<apex:commandButton value="Filter" action="{!search}" reRender="pnlId" >
</apex:commandButton>
<I>*Please use Refresh button to reset the filter applied. </I><br/>
<apex:pageBlockSection title="RTV - To be submitted for Approval" collapsible="false" id="sect" columns="1">
<apex:outputPanel layout="none" style="overflow:auto;height:380px" id="iddf" >
<apex:pageMessages id="ff" />
<apex:pageBlockTable value="{!lstSetController}" var="obj" Id="pbtblids">
<apex:column >
<apex:facet name="header">
<apex:outputText > Action</apex:outputText>
<apex:inputCheckbox label="Action" onclick="cvCheckAllOrNone(this)" title="Toggle All Rows"/>
</apex:facet>
<apex:inputCheckbox value="{!obj.isSelected}"/>
</apex:column>
<apex:repeat value="{!$ObjectType.Return_To_Vendor__c.FieldSets.RTVApprovalFieldSet}" var="f">
<apex:column >
<apex:variable value="{!SUBSTITUTE(f.fieldPath,'__c', '__r.Name')}" var="Name" rendered="{!if(f.type=='reference',true,false)}"/>
<apex:outputLink value="/{!obj.rtv[f]}" rendered="{!if(f.type=='reference', true, false)}" > {!obj.rtv[Name]}</apex:outputLink>
<apex:outputLink value="/{!obj.rtv['Id']}" rendered="{!if(f.FieldPath=='Name', true, false)}" > {!obj.rtv[f]}</apex:outputLink>
<!--<apex:outputtext value="{!obj.rtv[f]}" rendered="{!if(f.type=='reference' || f.FieldPath=='Name', false, true)}" />-->
<apex:outputField value="{!obj.rtv[f]}" rendered="{!if(f.type=='reference' || f.FieldPath=='Name', false, true)}" />
<apex:facet name="header">
<apex:commandLink value="{!f.Label}" status="statusMsg" action="{!sort}" reRender="pnlId">
<apex:param name="{!f.fieldPath}" assignTo="{!field}" value="{!f.FieldPath}"/>
<apex:param name="{!f.fieldPath+f.type}" assignTo="{!fieldType}" value="{!f.type}"/>
</apex:commandLink>
</apex:facet>
</apex:column>
<apex:outputText value="{!obj.rtv[f]}" /><br/>
</apex:repeat>
</apex:pageBlockTable>
<apex:commandButton value="<<Previous" action="{!previous}" status="statusMsg" rendered="{!hasPrevious}" reRender="pnlId" />
<apex:commandButton value="Next >>" action="{!next}" status="statusMsg" rendered="{!hasNext}" reRender="pnlId" />
</apex:outputPanel>
</apex:pageBlockSection>
<apex:pageBlockButtons location="top">
<apex:actionStatus onstart="showLoadingDiv();" onstop="hideLoadingDiv();" id="statusMsg">
<apex:facet name="start" >
<img src="/img/loading.gif" />
</apex:facet>
</apex:actionStatus>
<apex:commandButton action="{!SubmitForApproval}" value="Submit for Approval" status="statusMsg" reRender="pnlId,statusMsg "/>
<apex:commandButton action="{!refresh}" status="statusMsg" value="Refresh" rerender="pnlId"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:tab>
<apex:tab label="Items to Approve" name="name2" style="bachground-blend-mode:color-burn; background-color:white">
<apex:iframe src="/apex/RTV_My_Pending_Approvals" scrolling="true" id="theIframe" />
</apex:tab>
</apex:tabpanel>
</apex:page>
- Vinothini murugesh 10
- April 11, 2018
- Like
- 0
System.UnexpectedException: Search Term exceeded max length: in apex class
I am getting maximum lenght error in below line in my code. String sosl = 'FIND {' + String.join(new List(SAPs),' OR ') + '} IN ALL FIELDS RETURNING Contact (Id)';
my SAP contains 3125 SAP numbers. and it is trying to find the contact id of all
- Vinothini murugesh 10
- February 05, 2018
- Like
- 0
Insert failed. First exception on row 0; first error: STRING_TOO_LONG, Error Description: data value too large: Account_AU: execution of AfterUpdate caused by: System.AsyncException: Database.executeBatch cannot be called from a batch start, batch execut
i am getting error whie calling Batch_CustomerCategoryUpdate: my account has 1707 in account hierarchy
public static void updateCustomerCategories(List<Account> accountList, Map<Id, Account> oldAccts) {
map<string,Account> parentMap = new map<string,Account>();
map<string,list<Account>> childMap = new map<string,list<Account>>();
List<Account> updateAccount = new List<Account>();
Account accRef=new Account();
// if(!shouldRun('UpdateCustomerCategories')) return;
Set<Id> accIds = new Set<Id>();
Map<String,List<Account>> accInserIdMap = new Map<String,List<Account>>();
Map<String,List<Account>> accInserIdMap1 = new Map<String,List<Account>>();
for(Account acc:accountList){
Account oldAcct = null;
if(oldAccts != null && oldAccts.get(acc.Id) != null) {
oldAcct = oldAccts.get(acc.Id);
}
if(oldAcct != null){
if(( oldAcct.Customer_Categories_for_MC__c != acc.Customer_Categories_for_MC__c )) {
parentMap.put(acc.id,acc);
accIds.add(acc.Id);
system.debug('accids'+accIds.size()+accIds);
//if it is only one parent then updated account will be assigned to this account reference
accRef = acc;
}
}
//It is for Inserted records
if(oldAcct == null && acc.IsSoldTo__c==true){
// system.debug('insiode insert'+acc.parentid);
if(accInserIdMap.containskey(acc.parentid)){ //need to check when it will work
accInserIdMap.get(acc.parentid).add(acc);
accInserIdMap1.get(acc.DSE__DS_Ultimate_Parent__c).add(acc);
}
else{
accInserIdMap.put(acc.parentid,new List<Account>{acc});
accInserIdMap1.put(acc.DSE__DS_Ultimate_Parent__c,new List<Account>{acc});
}
}
else if(oldAcct != null && acc.IsSoldTo__C==true){
// system.debug('insiode update'+acc.parentid);
if(accInserIdMap.containskey(acc.parentid)){ //need to check when it will work
accInserIdMap.get(acc.parentid).add(acc);
accInserIdMap1.get(acc.DSE__DS_Ultimate_Parent__c).add(acc);
}
else{
accInserIdMap.put(acc.parentid,new List<Account>{acc});
accInserIdMap1.put(acc.DSE__DS_Ultimate_Parent__c,new List<Account>{acc});
}
}
}
Set<id> ultimateid=new set<id>();
//This loop only for inserted records.
if(accInserIdMap.size() > 0){
List<Account> accList = [select DSE__DS_Ultimate_Parent__c,Customer_Categories_for_MC__c,Customer_Category__c,Primary_Category_for_MC__c from Account where id in:accInserIdMap.keyset()];
system.debug(accList.size()+'accList############');
Set<string> newCatSet = new Set<string>();
List<Account> accList1 = [select DSE__DS_Ultimate_Parent__c,Customer_Categories_for_MC__c,Customer_Category__c,Primary_Category_for_MC__c from Account where id in:accInserIdMap1.keyset()];
if(accList.size() > 0 ){
for(Account acc:accList){
for(Account accUltimate:accList1){
for(Account accRefNew:accInserIdMap.get(acc.id)){
if(accRefNew.Customer_Categories_for_MC__c != null){
if(accList.size() > 0){
if(accList[0].Customer_Category__c!=null && accList[0].Customer_Category__c.split(';').size()>0){
Pattern nonAlphanumeric = Pattern.compile('[^a-zA-Z;\'/ ]');
Matcher matcher = nonAlphanumeric.matcher(string.escapeSingleQuotes(accList[0].Customer_Category__c));
string st =matcher.replaceAll('').trim().replace('; ', ';');
for(String stCat: st.split(';')){
newCatSet.add(stCat);
}
}
}
if(accRefNew.Customer_Category__c!=null && accRefNew.Customer_Category__c.split(';').size()>0){
Pattern nonAlphanumeric = Pattern.compile('[^a-zA-Z;\'/ ]');
Matcher matcher = nonAlphanumeric.matcher(string.escapeSingleQuotes(accRefNew.Customer_Category__c));
string st =matcher.replaceAll('').trim().replace('; ', ';');
for(String stCat: st.split(';')){
newCatSet.add(stCat);
}
}
/******************changes on 5th******************/
/**************changes made now***********************/
Set<String> catSet = new Set<String>();
if(acc.Customer_Categories_for_MC__c!=null){
for(String stCat: acc.Customer_Categories_for_MC__c.split(';')){
catSet.add(stCat);
}
}
for(String stCat: accRefNew.Customer_Categories_for_MC__c.split(';')){
catSet.add(stCat);
}
String custCategory = '';
String custCategoryMC = '';
Integer i=0;
for(String catValue : newCatSet){
i++;
custCategory += i+' '+catValue+';';
}
for(String catValue : catSet){
custCategoryMC += catValue+';';
}
custCategory= custCategory.substring(0,custCategory.length()-1);
custCategoryMC= custCategoryMC.substring(0,custCategoryMC.length()-1);
/**************changes made now***********************/
acc.Customer_Categories_for_MC__c = custCategoryMC;
acc.Primary_Category_for_MC__c = accRefNew.Primary_Category_for_MC__c;
acc.Customer_Category__c = custCategory;
accUltimate.Customer_Categories_for_MC__c=custCategoryMC;
accUltimate.Primary_Category_for_MC__c = accRefNew.Primary_Category_for_MC__c;
accUltimate.Customer_Category__c = custCategory;
}
}
}
update accList;
update accList1;
}
}
}
// The below loop will run for the update of the Account
System.debug('*** accIds size: ' +accIds.size());
System.debug('*** accIds size: ' +accIds);
if(!accIds.isEmpty()){
System.debug('*** accIds size: ' +accIds);
if(accIds.size()==1){
System.debug('*** accIds size inside 1 size: ' +accIds.size()+accIds);
getAllChildAccountIds(accIds);
System.debug('*** accUpdatenewList size: ' +accUpdatenewList.size());
for(Account acc:accUpdatenewList){
if(accRef.Customer_Categories_for_MC__c != null){
acc.Customer_Categories_for_MC__c = accRef.Customer_Categories_for_MC__c;
// if(acc.inherit__c == true){
acc.Customer_Category__c = accRef.Customer_Category__c;
acc.Primary_Category_for_MC__c = accRef.Customer_Categories_for_MC__c.split(';')[0];
// }
acc.IgnoreValidation__c = true;
}
}
System.debug('*** accIds size: ' +accUpdatenewList);
if(accUpdatenewList.size() > 0){
utility.IsAccountAfterupdateCalled=true;
toBeExecuted = false;//***RG
System.debug('toBeExecuted: ' +toBeExecuted);
// update accUpdatenewList;
if(accUpdatenewList.size() < 100){ //determine the best number to use based on limits with enough buffer
system.debug('inside batch'+accUpdatenewList.size());
update accUpdatenewList;
}else{
if([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND Status in ('Holding','Queued','Preparing','Processing')] < 100){
system.debug('inside batch'+accUpdatenewList.size());
categorySelectionBatch batch1 = new categorySelectionBatch(accUpdatenewList);
Id batch1Id = Database.executeBatch(batch1);
}else{
Account acct = new Account();
acct.addError('There are more than 100 batches of Apex code scheduled. Please try again after some time and if the issue repeats, log a case with LST Connect team');//Use a Label
}
}
}
}
else{
System.debug('*** accIds size: ' +accids.size());
System.debug('*** accIds size: ' +accids);
Database.executeBatch( new Batch_CustomerCategoryUpdate(accIds), (Test.isRunningTest() ? accIds.size() : accIds.size() ) );
}
}
}
public static void updateCustomerCategories(List<Account> accountList, Map<Id, Account> oldAccts) {
map<string,Account> parentMap = new map<string,Account>();
map<string,list<Account>> childMap = new map<string,list<Account>>();
List<Account> updateAccount = new List<Account>();
Account accRef=new Account();
// if(!shouldRun('UpdateCustomerCategories')) return;
Set<Id> accIds = new Set<Id>();
Map<String,List<Account>> accInserIdMap = new Map<String,List<Account>>();
Map<String,List<Account>> accInserIdMap1 = new Map<String,List<Account>>();
for(Account acc:accountList){
Account oldAcct = null;
if(oldAccts != null && oldAccts.get(acc.Id) != null) {
oldAcct = oldAccts.get(acc.Id);
}
if(oldAcct != null){
if(( oldAcct.Customer_Categories_for_MC__c != acc.Customer_Categories_for_MC__c )) {
parentMap.put(acc.id,acc);
accIds.add(acc.Id);
system.debug('accids'+accIds.size()+accIds);
//if it is only one parent then updated account will be assigned to this account reference
accRef = acc;
}
}
//It is for Inserted records
if(oldAcct == null && acc.IsSoldTo__c==true){
// system.debug('insiode insert'+acc.parentid);
if(accInserIdMap.containskey(acc.parentid)){ //need to check when it will work
accInserIdMap.get(acc.parentid).add(acc);
accInserIdMap1.get(acc.DSE__DS_Ultimate_Parent__c).add(acc);
}
else{
accInserIdMap.put(acc.parentid,new List<Account>{acc});
accInserIdMap1.put(acc.DSE__DS_Ultimate_Parent__c,new List<Account>{acc});
}
}
else if(oldAcct != null && acc.IsSoldTo__C==true){
// system.debug('insiode update'+acc.parentid);
if(accInserIdMap.containskey(acc.parentid)){ //need to check when it will work
accInserIdMap.get(acc.parentid).add(acc);
accInserIdMap1.get(acc.DSE__DS_Ultimate_Parent__c).add(acc);
}
else{
accInserIdMap.put(acc.parentid,new List<Account>{acc});
accInserIdMap1.put(acc.DSE__DS_Ultimate_Parent__c,new List<Account>{acc});
}
}
}
Set<id> ultimateid=new set<id>();
//This loop only for inserted records.
if(accInserIdMap.size() > 0){
List<Account> accList = [select DSE__DS_Ultimate_Parent__c,Customer_Categories_for_MC__c,Customer_Category__c,Primary_Category_for_MC__c from Account where id in:accInserIdMap.keyset()];
system.debug(accList.size()+'accList############');
Set<string> newCatSet = new Set<string>();
List<Account> accList1 = [select DSE__DS_Ultimate_Parent__c,Customer_Categories_for_MC__c,Customer_Category__c,Primary_Category_for_MC__c from Account where id in:accInserIdMap1.keyset()];
if(accList.size() > 0 ){
for(Account acc:accList){
for(Account accUltimate:accList1){
for(Account accRefNew:accInserIdMap.get(acc.id)){
if(accRefNew.Customer_Categories_for_MC__c != null){
if(accList.size() > 0){
if(accList[0].Customer_Category__c!=null && accList[0].Customer_Category__c.split(';').size()>0){
Pattern nonAlphanumeric = Pattern.compile('[^a-zA-Z;\'/ ]');
Matcher matcher = nonAlphanumeric.matcher(string.escapeSingleQuotes(accList[0].Customer_Category__c));
string st =matcher.replaceAll('').trim().replace('; ', ';');
for(String stCat: st.split(';')){
newCatSet.add(stCat);
}
}
}
if(accRefNew.Customer_Category__c!=null && accRefNew.Customer_Category__c.split(';').size()>0){
Pattern nonAlphanumeric = Pattern.compile('[^a-zA-Z;\'/ ]');
Matcher matcher = nonAlphanumeric.matcher(string.escapeSingleQuotes(accRefNew.Customer_Category__c));
string st =matcher.replaceAll('').trim().replace('; ', ';');
for(String stCat: st.split(';')){
newCatSet.add(stCat);
}
}
/******************changes on 5th******************/
/**************changes made now***********************/
Set<String> catSet = new Set<String>();
if(acc.Customer_Categories_for_MC__c!=null){
for(String stCat: acc.Customer_Categories_for_MC__c.split(';')){
catSet.add(stCat);
}
}
for(String stCat: accRefNew.Customer_Categories_for_MC__c.split(';')){
catSet.add(stCat);
}
String custCategory = '';
String custCategoryMC = '';
Integer i=0;
for(String catValue : newCatSet){
i++;
custCategory += i+' '+catValue+';';
}
for(String catValue : catSet){
custCategoryMC += catValue+';';
}
custCategory= custCategory.substring(0,custCategory.length()-1);
custCategoryMC= custCategoryMC.substring(0,custCategoryMC.length()-1);
/**************changes made now***********************/
acc.Customer_Categories_for_MC__c = custCategoryMC;
acc.Primary_Category_for_MC__c = accRefNew.Primary_Category_for_MC__c;
acc.Customer_Category__c = custCategory;
accUltimate.Customer_Categories_for_MC__c=custCategoryMC;
accUltimate.Primary_Category_for_MC__c = accRefNew.Primary_Category_for_MC__c;
accUltimate.Customer_Category__c = custCategory;
}
}
}
update accList;
update accList1;
}
}
}
// The below loop will run for the update of the Account
System.debug('*** accIds size: ' +accIds.size());
System.debug('*** accIds size: ' +accIds);
if(!accIds.isEmpty()){
System.debug('*** accIds size: ' +accIds);
if(accIds.size()==1){
System.debug('*** accIds size inside 1 size: ' +accIds.size()+accIds);
getAllChildAccountIds(accIds);
System.debug('*** accUpdatenewList size: ' +accUpdatenewList.size());
for(Account acc:accUpdatenewList){
if(accRef.Customer_Categories_for_MC__c != null){
acc.Customer_Categories_for_MC__c = accRef.Customer_Categories_for_MC__c;
// if(acc.inherit__c == true){
acc.Customer_Category__c = accRef.Customer_Category__c;
acc.Primary_Category_for_MC__c = accRef.Customer_Categories_for_MC__c.split(';')[0];
// }
acc.IgnoreValidation__c = true;
}
}
System.debug('*** accIds size: ' +accUpdatenewList);
if(accUpdatenewList.size() > 0){
utility.IsAccountAfterupdateCalled=true;
toBeExecuted = false;//***RG
System.debug('toBeExecuted: ' +toBeExecuted);
// update accUpdatenewList;
if(accUpdatenewList.size() < 100){ //determine the best number to use based on limits with enough buffer
system.debug('inside batch'+accUpdatenewList.size());
update accUpdatenewList;
}else{
if([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND Status in ('Holding','Queued','Preparing','Processing')] < 100){
system.debug('inside batch'+accUpdatenewList.size());
categorySelectionBatch batch1 = new categorySelectionBatch(accUpdatenewList);
Id batch1Id = Database.executeBatch(batch1);
}else{
Account acct = new Account();
acct.addError('There are more than 100 batches of Apex code scheduled. Please try again after some time and if the issue repeats, log a case with LST Connect team');//Use a Label
}
}
}
}
else{
System.debug('*** accIds size: ' +accids.size());
System.debug('*** accIds size: ' +accids);
Database.executeBatch( new Batch_CustomerCategoryUpdate(accIds), (Test.isRunningTest() ? accIds.size() : accIds.size() ) );
}
}
}
- Vinothini murugesh 10
- January 31, 2018
- Like
- 0
need help in writing test class for batch class
48% covered. from here it is not covering. here the value is coming as false if(!srList[i].isSuccess()){
}
global class categorySelectionBatch implements Database.Batchable<sObject> {
public List<Account> accts;
public categorySelectionBatch(List<Account> acctsToUpdate){
accts = acctsToUpdate;
}
global Iterable<sObject> start(Database.BatchableContext BC) {
return accts;
}
global void execute(Database.BatchableContext BC, List<sObject> sObjList) {
//error handling
List<Account> accountList = (List<Account>)sObjList;
Database.SaveResult[] srList = Database.update(accountList, false);
List<Error_Log__c> errorLogs = new List<Error_Log__c>();
for(Integer i=0; i < srList.size(); i++){
system.debug('!srList[i].isSuccess()'+srList[i].isSuccess()+'size'+srList.size());
if(!srList[i].isSuccess()){
String errorLog = String.valueof(srList[i].getErrors()[0].getStatusCode()).substring(0, math.min(String.valueof(srList[i].getErrors()[0].getStatusCode()).length(), 255));
String errorDesc = String.valueof(srList[i].getErrors()[0].getMessage()).substring(0, math.min(String.valueof(srList[i].getErrors()[0].getMessage()).length(), 1000));
errorLogs.add(new Error_Log__c(
Error_Log__c = errorLog,//1000
Error_Description__c = errorDesc,//255
Project__c = 'Customer_Category',
BatchId__c = BC.getJobId(),
Account_ID__c = accountList[i].Id,
CustomerCategoryId__c = accountList[i].Customer_Category__c
));
}
}
}
global void finish(Database.BatchableContext BC) {
Integer accountUpdateFailures = 0;
accountUpdateFailures = [Select count() from Error_Log__c where BatchId__c = :bc.getJobId()];
AsyncApexJob a = [Select Id, Status,ExtendedStatus,NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email from AsyncApexJob
where Id =:BC.getJobId()];
if(accountUpdateFailures > 0){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {a.CreatedBy.Email};
String[] CcAdddresses = new String[] {'Lst-CONNECT_SUPPORT@nike.com'};
mail.setToAddresses(toAddresses);
mail.setCcAddresses(CcAdddresses);
mail.setSubject('Customer Category update failed and its batchId:' +bc.getJobId());
mail.setPlainTextBody('Please log a case with Salesforce Connect team to process the failures. Please find more details in the Error Log object');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
}
global class categorySelectionBatch implements Database.Batchable<sObject> {
public List<Account> accts;
public categorySelectionBatch(List<Account> acctsToUpdate){
accts = acctsToUpdate;
}
global Iterable<sObject> start(Database.BatchableContext BC) {
return accts;
}
global void execute(Database.BatchableContext BC, List<sObject> sObjList) {
//error handling
List<Account> accountList = (List<Account>)sObjList;
Database.SaveResult[] srList = Database.update(accountList, false);
List<Error_Log__c> errorLogs = new List<Error_Log__c>();
for(Integer i=0; i < srList.size(); i++){
system.debug('!srList[i].isSuccess()'+srList[i].isSuccess()+'size'+srList.size());
if(!srList[i].isSuccess()){
String errorLog = String.valueof(srList[i].getErrors()[0].getStatusCode()).substring(0, math.min(String.valueof(srList[i].getErrors()[0].getStatusCode()).length(), 255));
String errorDesc = String.valueof(srList[i].getErrors()[0].getMessage()).substring(0, math.min(String.valueof(srList[i].getErrors()[0].getMessage()).length(), 1000));
errorLogs.add(new Error_Log__c(
Error_Log__c = errorLog,//1000
Error_Description__c = errorDesc,//255
Project__c = 'Customer_Category',
BatchId__c = BC.getJobId(),
Account_ID__c = accountList[i].Id,
CustomerCategoryId__c = accountList[i].Customer_Category__c
));
}
}
}
global void finish(Database.BatchableContext BC) {
Integer accountUpdateFailures = 0;
accountUpdateFailures = [Select count() from Error_Log__c where BatchId__c = :bc.getJobId()];
AsyncApexJob a = [Select Id, Status,ExtendedStatus,NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email from AsyncApexJob
where Id =:BC.getJobId()];
if(accountUpdateFailures > 0){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {a.CreatedBy.Email};
String[] CcAdddresses = new String[] {'Lst-CONNECT_SUPPORT@nike.com'};
mail.setToAddresses(toAddresses);
mail.setCcAddresses(CcAdddresses);
mail.setSubject('Customer Category update failed and its batchId:' +bc.getJobId());
mail.setPlainTextBody('Please log a case with Salesforce Connect team to process the failures. Please find more details in the Error Log object');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
}
- Vinothini murugesh 10
- January 25, 2018
- Like
- 0
System.AsyncException: Database.executeBatch cannot be called from a batch or future method. kindly hep me
global class Batch_CustomerCategoryUpdate implements Database.Batchable<sObject>{
public Static Set<Id> setAccountIds=new Set<Id>();
public Static Map<Id,String> mapString=new Map<Id,String>();
public Static String categories;
public set<Id> accIds;
public Static boolean skipAccountTrigger=false;
public Static List<Account> accUpdateList=new List<Account>();
public Batch_CustomerCategoryUpdate(Set<Id> tSetAccId){
// Get all the child account Ids
//getAllChildAccountIds(tsetAccId);
accIds=tsetAccId;
}
global Database.Querylocator Start(Database.batchableContext bc){
String strQuery='Select Id, Name, Customer_Category__c,Customer_Categories_for_MC__c,Primary_Category_for_MC__c from Account where id in :accIds';
system.debug('size od ids'+accIds.size());
system.debug(''+strQuery);
return Database.getQueryLocator(strQuery);
}
global void execute(Database.batchableContext bc,List<sObject> sObjList){
System.debug(''+setAccountIds.size()+' -setAccounIds- '+setAccountIds);
List<Account> accList=(List<Account>)sObjList;
if(accList[0].Customer_Categories_for_MC__c!=null){
Set<Id> setIds=new Set<Id>();
setIds.add(accList[0].Id);
getAllChildAccountIds(setIds);
for(Account acc:accUpdateList){
acc.Customer_Categories_for_MC__c = accList[0].Customer_Categories_for_MC__c;
acc.Customer_Category__c = accList[0].Customer_Category__c;
if(accList[0].Customer_Categories_for_MC__c.contains(';')){
acc.Primary_Category_for_MC__c = accList[0].Customer_Categories_for_MC__c.split(';')[0];
}
}
utility.IsAccountAfterUpdateCalled=true;
update accUpdateList;
}
}
global void finish(Database.batchableContext bc){
//Nothing
}
// Return list of all child Account Ids
public static void getAllChildAccountIds(set<Id> setAccId){
Set<Id> tempIdSet=new Set<Id>();
for(Account acc:[Select Id, name, Customer_Categories_for_MC__c,Customer_Category__c,inherit__c,Primary_Category_for_MC__c from Account where parentid in :setAccId and Synchronize__c=true ]){
accUpdateList.add(acc);
//for(Account ownr:acc.Accounts_OwnerGroup__r){
tempIdSet.add(acc.Id);
//}
//for(Account topn:acc.Accounts_TopNode__r){
//}
//for(Account sold:acc.SoldTo__r){
//}
}
if(tempIdSet.size()>0){
setAccountIds.addAll(tempIdSet);
getAllChildAccountIds(tempIdSet);
}
}
}
- Vinothini murugesh 10
- January 25, 2018
- Like
- 0
superbadge challenge8:Adventrue name not enabled while trying to insert opportunituy line item
superbadge challenge8
Adventure Name - Price Book Entry ID (Lookup via Adventure Name):
Adventure Name - Price Book Entry ID (Lookup via Adventure Name):
- Vinothini murugesh 10
- March 07, 2017
- Like
- 0
superbadge challenge8 issue: while inserting opportunity line item i a m getting filedintegrity exception for adventure name. in workbench i am unable to choose pricebookentry id lookup filed
superbadge challenge8 issue: while inserting opportunity line item i a m getting filedintegrity exception for adventure name. in workbench i am unable to choose pricebookentry id lookup filed
- Vinothini murugesh 10
- March 07, 2017
- Like
- 0
is it possible to use wild card certificate in salesforce
Hi Team,
I am creating CA certificate for the particular site in Salesforce. I want to create "Wild Card " certificate. Can i use common name as wild card name ?
I am creating CA certificate for the particular site in Salesforce. I want to create "Wild Card " certificate. Can i use common name as wild card name ?
- Vinothini murugesh 10
- July 01, 2019
- Like
- 0
i am getting view state error when i choose no.of records to 50 in my vf page.showing size is more than 135 kb.i have used Transient keyword and checked. still i m getting the error
<apex:page controller="RTV_ApprovalController" id="pageid" tabstyle="RTV_Approvals__tab">
<script>
function cvCheckAllOrNone(allOrNoneCheckbox) {
// Find parent table
var container = allOrNoneCheckbox;
while (container.tagName != "TABLE") {
container = container.parentNode;
}
// Switch all checkboxes
var inputs = container.getElementsByTagName("input");
var checked = allOrNoneCheckbox.checked;
for (var i = 0; i < inputs.length; i++) {
var input = inputs.item(i);
if (input.type == "checkbox") {
if (input != allOrNoneCheckbox) {
input.checked = checked;
}
}
}
}
</script>
<!-- Define Tab panel .css styles -->
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/versioning.css" />
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/extended.css" />
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/>
<script type="text/javascript">
j$ = jQuery.noConflict();
function showLoadingDiv() {
var newHeight = j$("[id$=pblkIds]").css("height");//Just shade the body, not the header
j$("[id$=loading-curtain-div]").css("background-color", "black").css("opacity", 0.35).css("height", newHeight).css("width", "80%");
}
function hideLoadingDiv() {
j$("[id$=loading-curtain-div]").css("background-color", "black").css("opacity", "1").css("height", "0px").css("width", "80%");
}
function getSelectedTabName() {
if (RichFaces) {
var tabs = RichFaces.panelTabs['pageid:form:tabpanel'];
for (var i = 0; i < tabs.length; i++) {
var tab = tabs[i];
if (RichFaces.isTabActive(tab.id + '_lbl')) {
return tab.name;
}
}
}
return null;
}
function setSelectedTabOnController() {
selectTabActionFunction(getSelectedTabName());
}
function select1(){
sel2();
}
function select2(){
sel2();
}
</script>
<style>
.activeTab {background-color: #236FBD; color:white; background-image:none}
.inactiveTab { background-color: black; color:black; background-image:none}
#loading-curtain-div {
height:0px;
width:100%;
position:absolute;
z-index:5;
-webkit-transition: all 0.30s ease-out;
-moz-transition: all 0.30s ease-out;
}
.no-js #loader { display: none; }
.js #loader { display: block; position: absolute; left: 100px; top: 0; }
.se-pre-con {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: URLFOR($Resource.preloader,'simple-pre-loader\images\loader-32x\loader1.gif') center no-repeat #fff;
}
</style>
<apex:tabPanel switchType="client" styleClass="theTabPanel" tabClass="theTabPanel" contentClass="tabContent" activeTabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="name1" id="tabpanel" >
<apex:tab label="RTV - To Submit for Approval" name="name1" reRender="pbIds" id="tabOne" style="bachground-blend-mode:color-burn; background-color:white">
<div id="loading-curtain-div"/>
<apex:form id="form" >
<apex:outputPanel id="pnlId" layout="none" >
<apex:pageBlock title="RTV - To Submit for Approval" id="pblkIds" >
<b>Select Region</b>
<apex:selectList value="{!selectedRegion}" size="1" title="Select Region" label="Select Region">
<apex:actionSupport event="onchange" action="{!getrefreshGrid}" status="statusMsg" reRender="pblkIds,pbIds"/>
<apex:selectOptions value="{!lstSelectOptions}"/>
</apex:selectList>
<b>No. of records per page:</b>
<apex:selectList value="{!pageSize}" size="1" title=" No. of records per page" label="No. of records per page">
<apex:actionSupport event="onchange" action="{!getrefreshGrid}" status="statusMsg" reRender="pblkIds,pbIds"/>
<apex:selectOption itemLabel="10" itemValue="10" />
<apex:selectOption itemLabel="20" itemValue="20" />
<apex:selectOption itemLabel="50" itemValue="50" />
<apex:selectOption itemLabel="100" itemValue="100" />
</apex:selectList><br/><br/>
<b> Filter Text</b>
<apex:inputText value="{!searchText}" />
<apex:commandButton value="Filter" action="{!search}" reRender="pnlId" >
</apex:commandButton>
<I>*Please use Refresh button to reset the filter applied. </I><br/>
<apex:pageBlockSection title="RTV - To be submitted for Approval" collapsible="false" id="sect" columns="1">
<apex:outputPanel layout="none" style="overflow:auto;height:380px" id="iddf" >
<apex:pageMessages id="ff" />
<apex:pageBlockTable value="{!lstSetController}" var="obj" Id="pbtblids">
<apex:column >
<apex:facet name="header">
<apex:outputText > Action</apex:outputText>
<apex:inputCheckbox label="Action" onclick="cvCheckAllOrNone(this)" title="Toggle All Rows"/>
</apex:facet>
<apex:inputCheckbox value="{!obj.isSelected}"/>
</apex:column>
<apex:repeat value="{!$ObjectType.Return_To_Vendor__c.FieldSets.RTVApprovalFieldSet}" var="f">
<apex:column >
<apex:variable value="{!SUBSTITUTE(f.fieldPath,'__c', '__r.Name')}" var="Name" rendered="{!if(f.type=='reference',true,false)}"/>
<apex:outputLink value="/{!obj.rtv[f]}" rendered="{!if(f.type=='reference', true, false)}" > {!obj.rtv[Name]}</apex:outputLink>
<apex:outputLink value="/{!obj.rtv['Id']}" rendered="{!if(f.FieldPath=='Name', true, false)}" > {!obj.rtv[f]}</apex:outputLink>
<!--<apex:outputtext value="{!obj.rtv[f]}" rendered="{!if(f.type=='reference' || f.FieldPath=='Name', false, true)}" />-->
<apex:outputField value="{!obj.rtv[f]}" rendered="{!if(f.type=='reference' || f.FieldPath=='Name', false, true)}" />
<apex:facet name="header">
<apex:commandLink value="{!f.Label}" status="statusMsg" action="{!sort}" reRender="pnlId">
<apex:param name="{!f.fieldPath}" assignTo="{!field}" value="{!f.FieldPath}"/>
<apex:param name="{!f.fieldPath+f.type}" assignTo="{!fieldType}" value="{!f.type}"/>
</apex:commandLink>
</apex:facet>
</apex:column>
<apex:outputText value="{!obj.rtv[f]}" /><br/>
</apex:repeat>
</apex:pageBlockTable>
<apex:commandButton value="<<Previous" action="{!previous}" status="statusMsg" rendered="{!hasPrevious}" reRender="pnlId" />
<apex:commandButton value="Next >>" action="{!next}" status="statusMsg" rendered="{!hasNext}" reRender="pnlId" />
</apex:outputPanel>
</apex:pageBlockSection>
<apex:pageBlockButtons location="top">
<apex:actionStatus onstart="showLoadingDiv();" onstop="hideLoadingDiv();" id="statusMsg">
<apex:facet name="start" >
<img src="/img/loading.gif" />
</apex:facet>
</apex:actionStatus>
<apex:commandButton action="{!SubmitForApproval}" value="Submit for Approval" status="statusMsg" reRender="pnlId,statusMsg "/>
<apex:commandButton action="{!refresh}" status="statusMsg" value="Refresh" rerender="pnlId"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:tab>
<apex:tab label="Items to Approve" name="name2" style="bachground-blend-mode:color-burn; background-color:white">
<apex:iframe src="/apex/RTV_My_Pending_Approvals" scrolling="true" id="theIframe" />
</apex:tab>
</apex:tabpanel>
</apex:page>
<script>
function cvCheckAllOrNone(allOrNoneCheckbox) {
// Find parent table
var container = allOrNoneCheckbox;
while (container.tagName != "TABLE") {
container = container.parentNode;
}
// Switch all checkboxes
var inputs = container.getElementsByTagName("input");
var checked = allOrNoneCheckbox.checked;
for (var i = 0; i < inputs.length; i++) {
var input = inputs.item(i);
if (input.type == "checkbox") {
if (input != allOrNoneCheckbox) {
input.checked = checked;
}
}
}
}
</script>
<!-- Define Tab panel .css styles -->
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/versioning.css" />
<apex:stylesheet value="/sCSS/21.0/sprites/1297816277000/Theme3/default/gc/extended.css" />
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/>
<script type="text/javascript">
j$ = jQuery.noConflict();
function showLoadingDiv() {
var newHeight = j$("[id$=pblkIds]").css("height");//Just shade the body, not the header
j$("[id$=loading-curtain-div]").css("background-color", "black").css("opacity", 0.35).css("height", newHeight).css("width", "80%");
}
function hideLoadingDiv() {
j$("[id$=loading-curtain-div]").css("background-color", "black").css("opacity", "1").css("height", "0px").css("width", "80%");
}
function getSelectedTabName() {
if (RichFaces) {
var tabs = RichFaces.panelTabs['pageid:form:tabpanel'];
for (var i = 0; i < tabs.length; i++) {
var tab = tabs[i];
if (RichFaces.isTabActive(tab.id + '_lbl')) {
return tab.name;
}
}
}
return null;
}
function setSelectedTabOnController() {
selectTabActionFunction(getSelectedTabName());
}
function select1(){
sel2();
}
function select2(){
sel2();
}
</script>
<style>
.activeTab {background-color: #236FBD; color:white; background-image:none}
.inactiveTab { background-color: black; color:black; background-image:none}
#loading-curtain-div {
height:0px;
width:100%;
position:absolute;
z-index:5;
-webkit-transition: all 0.30s ease-out;
-moz-transition: all 0.30s ease-out;
}
.no-js #loader { display: none; }
.js #loader { display: block; position: absolute; left: 100px; top: 0; }
.se-pre-con {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: URLFOR($Resource.preloader,'simple-pre-loader\images\loader-32x\loader1.gif') center no-repeat #fff;
}
</style>
<apex:tabPanel switchType="client" styleClass="theTabPanel" tabClass="theTabPanel" contentClass="tabContent" activeTabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="name1" id="tabpanel" >
<apex:tab label="RTV - To Submit for Approval" name="name1" reRender="pbIds" id="tabOne" style="bachground-blend-mode:color-burn; background-color:white">
<div id="loading-curtain-div"/>
<apex:form id="form" >
<apex:outputPanel id="pnlId" layout="none" >
<apex:pageBlock title="RTV - To Submit for Approval" id="pblkIds" >
<b>Select Region</b>
<apex:selectList value="{!selectedRegion}" size="1" title="Select Region" label="Select Region">
<apex:actionSupport event="onchange" action="{!getrefreshGrid}" status="statusMsg" reRender="pblkIds,pbIds"/>
<apex:selectOptions value="{!lstSelectOptions}"/>
</apex:selectList>
<b>No. of records per page:</b>
<apex:selectList value="{!pageSize}" size="1" title=" No. of records per page" label="No. of records per page">
<apex:actionSupport event="onchange" action="{!getrefreshGrid}" status="statusMsg" reRender="pblkIds,pbIds"/>
<apex:selectOption itemLabel="10" itemValue="10" />
<apex:selectOption itemLabel="20" itemValue="20" />
<apex:selectOption itemLabel="50" itemValue="50" />
<apex:selectOption itemLabel="100" itemValue="100" />
</apex:selectList><br/><br/>
<b> Filter Text</b>
<apex:inputText value="{!searchText}" />
<apex:commandButton value="Filter" action="{!search}" reRender="pnlId" >
</apex:commandButton>
<I>*Please use Refresh button to reset the filter applied. </I><br/>
<apex:pageBlockSection title="RTV - To be submitted for Approval" collapsible="false" id="sect" columns="1">
<apex:outputPanel layout="none" style="overflow:auto;height:380px" id="iddf" >
<apex:pageMessages id="ff" />
<apex:pageBlockTable value="{!lstSetController}" var="obj" Id="pbtblids">
<apex:column >
<apex:facet name="header">
<apex:outputText > Action</apex:outputText>
<apex:inputCheckbox label="Action" onclick="cvCheckAllOrNone(this)" title="Toggle All Rows"/>
</apex:facet>
<apex:inputCheckbox value="{!obj.isSelected}"/>
</apex:column>
<apex:repeat value="{!$ObjectType.Return_To_Vendor__c.FieldSets.RTVApprovalFieldSet}" var="f">
<apex:column >
<apex:variable value="{!SUBSTITUTE(f.fieldPath,'__c', '__r.Name')}" var="Name" rendered="{!if(f.type=='reference',true,false)}"/>
<apex:outputLink value="/{!obj.rtv[f]}" rendered="{!if(f.type=='reference', true, false)}" > {!obj.rtv[Name]}</apex:outputLink>
<apex:outputLink value="/{!obj.rtv['Id']}" rendered="{!if(f.FieldPath=='Name', true, false)}" > {!obj.rtv[f]}</apex:outputLink>
<!--<apex:outputtext value="{!obj.rtv[f]}" rendered="{!if(f.type=='reference' || f.FieldPath=='Name', false, true)}" />-->
<apex:outputField value="{!obj.rtv[f]}" rendered="{!if(f.type=='reference' || f.FieldPath=='Name', false, true)}" />
<apex:facet name="header">
<apex:commandLink value="{!f.Label}" status="statusMsg" action="{!sort}" reRender="pnlId">
<apex:param name="{!f.fieldPath}" assignTo="{!field}" value="{!f.FieldPath}"/>
<apex:param name="{!f.fieldPath+f.type}" assignTo="{!fieldType}" value="{!f.type}"/>
</apex:commandLink>
</apex:facet>
</apex:column>
<apex:outputText value="{!obj.rtv[f]}" /><br/>
</apex:repeat>
</apex:pageBlockTable>
<apex:commandButton value="<<Previous" action="{!previous}" status="statusMsg" rendered="{!hasPrevious}" reRender="pnlId" />
<apex:commandButton value="Next >>" action="{!next}" status="statusMsg" rendered="{!hasNext}" reRender="pnlId" />
</apex:outputPanel>
</apex:pageBlockSection>
<apex:pageBlockButtons location="top">
<apex:actionStatus onstart="showLoadingDiv();" onstop="hideLoadingDiv();" id="statusMsg">
<apex:facet name="start" >
<img src="/img/loading.gif" />
</apex:facet>
</apex:actionStatus>
<apex:commandButton action="{!SubmitForApproval}" value="Submit for Approval" status="statusMsg" reRender="pnlId,statusMsg "/>
<apex:commandButton action="{!refresh}" status="statusMsg" value="Refresh" rerender="pnlId"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:tab>
<apex:tab label="Items to Approve" name="name2" style="bachground-blend-mode:color-burn; background-color:white">
<apex:iframe src="/apex/RTV_My_Pending_Approvals" scrolling="true" id="theIframe" />
</apex:tab>
</apex:tabpanel>
</apex:page>
- Vinothini murugesh 10
- April 11, 2018
- Like
- 0
System.AsyncException: Database.executeBatch cannot be called from a batch or future method. kindly hep me
global class Batch_CustomerCategoryUpdate implements Database.Batchable<sObject>{
public Static Set<Id> setAccountIds=new Set<Id>();
public Static Map<Id,String> mapString=new Map<Id,String>();
public Static String categories;
public set<Id> accIds;
public Static boolean skipAccountTrigger=false;
public Static List<Account> accUpdateList=new List<Account>();
public Batch_CustomerCategoryUpdate(Set<Id> tSetAccId){
// Get all the child account Ids
//getAllChildAccountIds(tsetAccId);
accIds=tsetAccId;
}
global Database.Querylocator Start(Database.batchableContext bc){
String strQuery='Select Id, Name, Customer_Category__c,Customer_Categories_for_MC__c,Primary_Category_for_MC__c from Account where id in :accIds';
system.debug('size od ids'+accIds.size());
system.debug(''+strQuery);
return Database.getQueryLocator(strQuery);
}
global void execute(Database.batchableContext bc,List<sObject> sObjList){
System.debug(''+setAccountIds.size()+' -setAccounIds- '+setAccountIds);
List<Account> accList=(List<Account>)sObjList;
if(accList[0].Customer_Categories_for_MC__c!=null){
Set<Id> setIds=new Set<Id>();
setIds.add(accList[0].Id);
getAllChildAccountIds(setIds);
for(Account acc:accUpdateList){
acc.Customer_Categories_for_MC__c = accList[0].Customer_Categories_for_MC__c;
acc.Customer_Category__c = accList[0].Customer_Category__c;
if(accList[0].Customer_Categories_for_MC__c.contains(';')){
acc.Primary_Category_for_MC__c = accList[0].Customer_Categories_for_MC__c.split(';')[0];
}
}
utility.IsAccountAfterUpdateCalled=true;
update accUpdateList;
}
}
global void finish(Database.batchableContext bc){
//Nothing
}
// Return list of all child Account Ids
public static void getAllChildAccountIds(set<Id> setAccId){
Set<Id> tempIdSet=new Set<Id>();
for(Account acc:[Select Id, name, Customer_Categories_for_MC__c,Customer_Category__c,inherit__c,Primary_Category_for_MC__c from Account where parentid in :setAccId and Synchronize__c=true ]){
accUpdateList.add(acc);
//for(Account ownr:acc.Accounts_OwnerGroup__r){
tempIdSet.add(acc.Id);
//}
//for(Account topn:acc.Accounts_TopNode__r){
//}
//for(Account sold:acc.SoldTo__r){
//}
}
if(tempIdSet.size()>0){
setAccountIds.addAll(tempIdSet);
getAllChildAccountIds(tempIdSet);
}
}
}
- Vinothini murugesh 10
- January 25, 2018
- Like
- 0
CPU Time Limit exceeded error for my code.please help me to solve this
Trigger:
trigger UpdateRelIntConIds5 on Contract_Group_Association__c (after delete, after insert, after update) {
Set<Id> accounts = new Set<Id>();
Map<id,id> contractgroupid=new Map<id,id>();
Set<Id> cons = new Set<Id>();
Set<Id> contracts = new Set<Id>();
system.debug('old'+Trigger.old );
if (Trigger.old != null) {
system.debug('inside update');
for (Contract_Group_Association__c c : Trigger.old) {
if (c.Internal_Contract_Group__c != null)
cons.add(c.Internal_Contract_Group__c);
}
}
if (Trigger.new != null) {
system.debug('inside insert');
for (Contract_Group_Association__c c : Trigger.new) {
if (c.Internal_Contract_Group__c != null)
cons.add(c.Internal_Contract_Group__c);
}
}
if (cons.size()> 0){
List<Customer_Groups_Association__c> conGroup = [select Internal_Contact_Group__c,Internal_Contract_Group__c from Customer_Groups_Association__c where Internal_Contract_Group__c in :cons];
system.debug('conGroup'+conGroup.size());
for (Customer_Groups_Association__c cx : conGroup) {
accounts.add(cx.Internal_Contact_Group__c);
contractgroupid.put(cx.id,cx.Internal_Contract_Group__c);
system.debug('cx.Internal_Contact_Group__c: '+cx.Internal_Contact_Group__c);
}
}
system.debug('Groups'+accounts);
UpdateRelatedInternalContractIds ur = new UpdateRelatedInternalContractIds(accounts,contractgroupid);
ur.go();
}
apex class:
global class UpdateRelatedInternalContractIds {
public Set<Id> accounts {get; set;}
public Map<id,id> contractgroupid {get; set;}
public UpdateRelatedInternalContractIds(Set<Id> accounts,map<id,id> contractgroupid) {
this.accounts = accounts;
this.contractgroupid= contractgroupid;
}
public void go() {
Set<Id> contractGroups = new Set<Id>();
Map<String, Set<String>> customers = new Map<String, Set<String>>();
if (accounts == null)
return;
List<Customer_Groups_Association__c> clist = [select id, Internal_Contract_Group__c, Internal_Contact_Group__c from Customer_Groups_Association__c where Internal_Contact_Group__c in :accounts];
if (clist != null) {
for (Customer_Groups_Association__c c : clist) {
contractGroups.add(c.Internal_Contract_Group__c);
Set<String> t = customers.get(c.Internal_Contact_Group__c);
if (t == null) {
t = new Set<String>();
customers.put(c.Internal_Contact_Group__c, t);
}
t.add(c.Internal_Contract_Group__c);
}
}
Map<String, Set<String>> contractIds = new Map<String, Set<String>>();
List<Contract_Group_Association__c> dlist = [select id, Internal_Contract__r.Internal_Contract_ID__c, Internal_Contract_Group__c from Contract_Group_Association__c where Internal_Contract_Group__c in :contractGroups];
if (dlist != null) {
for (Contract_Group_Association__c d : dlist) {
Set<String> t = contractIds.get(d.Internal_Contract_Group__c);
if (t == null) {
t = new Set<String>();
contractIds.put(d.Internal_Contract_Group__c, t);
}
t.add(d.Internal_Contract__r.Internal_Contract_ID__c);
}
}
List<Account> customerList = [select id, Related_Internal_Contract_IDs__c from Account where id in :accounts];
for (Account c : customerList) {
String result = '';
if (customers.containsKey(c.id)) {
system.debug('customer@@' + c);
for (String s : customers.get(c.id)) {
if (!contractIds.containsKey(s))
continue;
for (String x : contractIds.get(s)) {
if (result != '')
result += ',';
result += x;
}
}
}
c.Related_Internal_Contract_IDs__c = result;
}
update customerList;
}
trigger UpdateRelIntConIds5 on Contract_Group_Association__c (after delete, after insert, after update) {
Set<Id> accounts = new Set<Id>();
Map<id,id> contractgroupid=new Map<id,id>();
Set<Id> cons = new Set<Id>();
Set<Id> contracts = new Set<Id>();
system.debug('old'+Trigger.old );
if (Trigger.old != null) {
system.debug('inside update');
for (Contract_Group_Association__c c : Trigger.old) {
if (c.Internal_Contract_Group__c != null)
cons.add(c.Internal_Contract_Group__c);
}
}
if (Trigger.new != null) {
system.debug('inside insert');
for (Contract_Group_Association__c c : Trigger.new) {
if (c.Internal_Contract_Group__c != null)
cons.add(c.Internal_Contract_Group__c);
}
}
if (cons.size()> 0){
List<Customer_Groups_Association__c> conGroup = [select Internal_Contact_Group__c,Internal_Contract_Group__c from Customer_Groups_Association__c where Internal_Contract_Group__c in :cons];
system.debug('conGroup'+conGroup.size());
for (Customer_Groups_Association__c cx : conGroup) {
accounts.add(cx.Internal_Contact_Group__c);
contractgroupid.put(cx.id,cx.Internal_Contract_Group__c);
system.debug('cx.Internal_Contact_Group__c: '+cx.Internal_Contact_Group__c);
}
}
system.debug('Groups'+accounts);
UpdateRelatedInternalContractIds ur = new UpdateRelatedInternalContractIds(accounts,contractgroupid);
ur.go();
}
apex class:
global class UpdateRelatedInternalContractIds {
public Set<Id> accounts {get; set;}
public Map<id,id> contractgroupid {get; set;}
public UpdateRelatedInternalContractIds(Set<Id> accounts,map<id,id> contractgroupid) {
this.accounts = accounts;
this.contractgroupid= contractgroupid;
}
public void go() {
Set<Id> contractGroups = new Set<Id>();
Map<String, Set<String>> customers = new Map<String, Set<String>>();
if (accounts == null)
return;
List<Customer_Groups_Association__c> clist = [select id, Internal_Contract_Group__c, Internal_Contact_Group__c from Customer_Groups_Association__c where Internal_Contact_Group__c in :accounts];
if (clist != null) {
for (Customer_Groups_Association__c c : clist) {
contractGroups.add(c.Internal_Contract_Group__c);
Set<String> t = customers.get(c.Internal_Contact_Group__c);
if (t == null) {
t = new Set<String>();
customers.put(c.Internal_Contact_Group__c, t);
}
t.add(c.Internal_Contract_Group__c);
}
}
Map<String, Set<String>> contractIds = new Map<String, Set<String>>();
List<Contract_Group_Association__c> dlist = [select id, Internal_Contract__r.Internal_Contract_ID__c, Internal_Contract_Group__c from Contract_Group_Association__c where Internal_Contract_Group__c in :contractGroups];
if (dlist != null) {
for (Contract_Group_Association__c d : dlist) {
Set<String> t = contractIds.get(d.Internal_Contract_Group__c);
if (t == null) {
t = new Set<String>();
contractIds.put(d.Internal_Contract_Group__c, t);
}
t.add(d.Internal_Contract__r.Internal_Contract_ID__c);
}
}
List<Account> customerList = [select id, Related_Internal_Contract_IDs__c from Account where id in :accounts];
for (Account c : customerList) {
String result = '';
if (customers.containsKey(c.id)) {
system.debug('customer@@' + c);
for (String s : customers.get(c.id)) {
if (!contractIds.containsKey(s))
continue;
for (String x : contractIds.get(s)) {
if (result != '')
result += ',';
result += x;
}
}
}
c.Related_Internal_Contract_IDs__c = result;
}
update customerList;
}
- Vinothini Murugesh 23
- January 04, 2018
- Like
- 0
Stuck in trailhead - Lightning Components Basics-Connect Components with Events
I am stuc on this challenge and its very frustrating.
For some reason I cannot save the component code, i get an error message when trying to save:
Failed to save undefined: No EVENT named markup://c:addItemEvent found : [markup://c:campinglist]: Source
Here is the code im trying to save. anyone know why it wont allow me to save it?
<aura:component controller="CampingListController">
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/>
<div class="slds-page-header" role="banner">
<div class="slds-grid">
<div class="slds-col">
<p class="slds-text-heading--label">Camping Items</p>
<h1 class="slds-text-heading--medium">My Camping Items</h1>
</div>
</div>
</div>
<div aria-labelledby="newitemform">
<fieldset class="slds-box slds-theme--default slds-container--small">
<c:campingListForm />
</fieldset>
</div>
<aura:attribute name="items" type="Camping_Item__c[]"/>
<div class="slds-card slds-p-top--medium">
<header class="slds-card__header">
<h3 class="slds-text-heading--small">Camping List Items</h3>
</header>
<section class="slds-card__body">
<div id="list" class="row">
<aura:iteration items="{!v.items}" var="item">
<c:campingListItem item="{!item}"/>
</aura:iteration>
</div>
</section>
</div>
</aura:component>
For some reason I cannot save the component code, i get an error message when trying to save:
Failed to save undefined: No EVENT named markup://c:addItemEvent found : [markup://c:campinglist]: Source
Here is the code im trying to save. anyone know why it wont allow me to save it?
<aura:component controller="CampingListController">
<aura:handler name="init" action="{!c.doInit}" value="{!this}"/>
<aura:handler name="addItem" event="c:addItemEvent" action="{!c.handleAddItem}"/>
<div class="slds-page-header" role="banner">
<div class="slds-grid">
<div class="slds-col">
<p class="slds-text-heading--label">Camping Items</p>
<h1 class="slds-text-heading--medium">My Camping Items</h1>
</div>
</div>
</div>
<div aria-labelledby="newitemform">
<fieldset class="slds-box slds-theme--default slds-container--small">
<c:campingListForm />
</fieldset>
</div>
<aura:attribute name="items" type="Camping_Item__c[]"/>
<div class="slds-card slds-p-top--medium">
<header class="slds-card__header">
<h3 class="slds-text-heading--small">Camping List Items</h3>
</header>
<section class="slds-card__body">
<div id="list" class="row">
<aura:iteration items="{!v.items}" var="item">
<c:campingListItem item="{!item}"/>
</aura:iteration>
</div>
</section>
</div>
</aura:component>
- Derek Bennett 5
- December 10, 2016
- Like
- 0
Challenge Not yet complete... here's what's wrong: The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly.
Hi, I am having trouble with the "Attributes and Expressions" module from trailhead.
Here is the challenge:
Create a Lightning Component to display a single item for your packing list.
The error that I am getting is: "Challenge Not yet complete... here's what's wrong:
The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly."
With this, I tried to create another component, with the name "packingListItem", but It didn't work.
Can anyone help me?
Thanks,
Here is the challenge:
Create a Lightning Component to display a single item for your packing list.
- Create a component called campingListItem that displays the name (ui:outputText) and the three custom fields using the appropriate output components.
- Add an attribute named 'item' for type Camping_Item__c.
<aura:component > <aura:attribute name="item" type="<my_domain>__Camping_Item__c"/> <ui:outputText value="{!v.item.Name}"/> <ui:outputCheckbox value="{!v.item.<my_domain>__Packed__c}"/> <ui:outputCurrency value="{!v.item.<my_domain>__Price__c}"/> <ui:outputNumber value="{!v.item.<my_domain>__Quantity__c}"/> </aura:component>
The error that I am getting is: "Challenge Not yet complete... here's what's wrong:
The packingListItem Lightning Component's attribute tag doesn't exist or its attributes are not set correctly."
With this, I tried to create another component, with the name "packingListItem", but It didn't work.
Can anyone help me?
Thanks,
- Eric Kendi Shiraishi
- June 06, 2016
- Like
- 4