• divya1234
  • NEWBIE
  • 70 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 53
    Questions
  • 37
    Replies
I am trying to enable offline mode for few salesforce object .I have enabled offline mode for both android and  IOS, Also created a briefcase builder for the required object 

Have done same configuration in my developer org i was able to see all the object on offline preferences but in sandbox just dashboard and tasks are available

Is there limitation with sandbox
#offline mode
Lightning Button is not navigating a page to custom object record page. when i cick on navigate button nothing is happning. What am i missing here? i  am trying to navigate to custom object record page from lightning componenent
 
// Component Button
<lightning:navigation aura:id ="navService"/>

<div class="slds-p-top_medium">
                <lightning:button value ="Navigate" label="Navigate"  onclick="{!c.navigateENT}" />
     </div>

//helper Method

 navigateENT: function(component, event, helper) {
       var navService =  component.find("navService");
       var pageReference = {            
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Request__c',
                actionName: 'list'
            },
            state: {
               filterName: 'Recent'
            }
        };
        navService.navigate(pageReference);
    },

 
I am trying to redirect  to the custom object record page after action in persfored by lightning button
Helper: function(component, event, getInputkeyWord) {
        // call the apex class method 
        var action = component.get("c.Function");// calling a method from aura enable class to persfor a opeation
        // set param to method  
        action.setParams({
            'Records': component.get("v.NextRecords")
        });
        // set a callBack    
        action.setCallback(this, function(response) {

            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                // if storeResponse size is equal 0 ,display No Records Found... message on screen.                }
                if (storeResponse.length == 0) {
                    component.set("v.Message", 'No Records Found...');
                } else {
                    component.set("v.Message", '');
                    // set searchResult list with return value from server.
                }
                component.set("v.UserList", storeResponse);
                alert('operation perfored  Sucessfully'); // showing a message once operation is completed
				/// trying to redirect the page from lightning component page to record detai page
               var navEvent = $A.get("e.force:navigateToSObject");
              navEvent.setParams({
              recordId: component.get("v.objSobject").Id,
              slideDevName: "detail"
         });
         navEvent.fire();

I am getting This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'setParams' of undefined] Callback failed: apex://ETre/AuarApexClass/ACTION$UserFunction Failing descriptor: {markup://c:MultiSelectLookup}
I have to create a VF page which refresh in every 2 minuts until field value is updated(field value is getting updated by future method) i wan to show one progress bar until field value is updated "saying ur request is in progress" once  field value is updated i want to show in su
<apex:page  standardController="Request__c">
	<html>
		<head>
            <META http-equiv="refresh" content="3"/>
		</head>
	</html>
// how to show the progress bar in VF?
</apex:page>

cess message 
I have a situation where i want to display the field value which should show sub string value of field inside aura iteration eg email field is test1.user1@gmail.com i want to display value as test1.user1. ho can i achieve this?
<th data-label="Id" scope="row">
          <div class="slds-truncate" title="Cloudhub">
        <a href="{!'/one/one.app?#/sObject/'+ singleRec.Id + '/view'}" target="_blank">{!singleRec.Email}</a>                                           </div>
                                        </th>

 
-2
I have a Requirement to select multiple user on my lookup field . I have one custom Object called Provisioning where i have lookup field for user object . Current functionally is if i select the user record it will update the field on user object via trigger. New Requirement is it should allow user to select Multiple user on user lookup field . how i ca achieve this with VF page or Lightning Component. If i am creating a VF page how do I add the selected values of lookup as individual rows in parent page??
i have requirement to create a case if case was not being created manually for that month for particular accounts. i have stored all account in custom object (where i am going to store the account which i want to apply above proceed. i am not sure what query i should write
 
global class BatchCaseRecord implements Database.Batchable<sObject> {
    global final string query;
    DateTime dt = DateTime.now();
    String monthName = dt.format('MMMMM');
    Integer year = Date.today().year();
    global Database.QueryLocator start(Database.BatchableContext bc) {
// what will be query to get the record which need to processed 
        string query = 'SELECT Account__c FROM CaseRecord_Account__c Limit 2000';

        return Database.getQueryLocator(query);
    }
    global void execute(Database.BatchableContext bc, List<CaseRecord_Account__c> CNbatch) {
        List<Case> caserecords = new List<Case>();
        String rtype = [select id from recordtype where sobjecttype = 'Case' and name = 'CaseRecord'].id;
        for (CaseRecord_Account__c CN : CNbatch) {
            for (integer i = 0; i < AccountList.size; i++) {
                //        
                //what will be if codition to check if case is not created this month 
                case c1 = new case();

                c1.Month__c = monthName.left(3);
                c1.Year__c = String.valueOf(year);
                c1.Reason__c = 'Phone';
                c1.RecordTypeId = rtype;
                c1.Client_Account__c = CN.Account__c;
                caserecords.add(c1);
                if (!caserecords.isEmpty()) {
                    database.insert(caserecords, false);
                }
            }
        }
    }
//}
/// send the email to account user for those case is created


    global void finish(Database.BatchableContext bc) {
        AsyncApexJob a = [Select Id, Status,ExtendedStatus,NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email from AsyncApexJob where Id = :BC.getJobId()];
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[]{
                a.CreatedBy.Email
        };
        mail.setToAddresses(toAddresses);
        mail.setSubject('Match Merge Batch ' + a.Status);
        mail.setPlainTextBody('records processed ' + a.TotalJobItems + 'with ' + a.NumberOfErrors + ' failures.');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[]{
                mail
        });
    }
}

 
I'm new to developing in general and I am trying to create a trigger that updates the custom lookup field Test1__c and account__c on the custom object test2  object. I have a created a custom object called test2  o  which has a related one-to-one relationship with the Account and test 1. I'm getting an error when attempting to save the Opportunity record, although it mentions the correct reference below but doesnt populate the field. My code is pasted below the error message."Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Populatetest2caused an unexpected exception, contact your administrator: Populatetest2 : data changed by trigger for field Repcode: data value too large: (value has been hidden)"
 
trigger PopulateTest2 on Test1(before insert,before update) {
    set<ID> setofTest2 = new set<id>();
    set<ID> setofContactUser     = new set<id>();
    for (Test1 CA : trigger.new){
        if(CA.Test2_Name__c != null){
            setofTest2.add(CA.Test2_Name__c);}
        if(CA.ContactUser__c!=null){
            setofContactUser.add(CA.ContactUser__c); }   }       
        List<Test2__c> Test2List  = [Select ContactUser__c from Test2__c where id in: setofTest2];
        List<Account>  AccList = [Select Name from Account where id in: setofContactUser];    
     for(Integer i = 0; i < Trigger.new.size(); i++){
        if (Trigger.new[i].Test2__c != null) {
           Trigger.new[i].Test2__c = Test2List[i].ID;            
        }
        if (Trigger.new[i].ContactUser__c != null) {
           Trigger.new[i].ContactUser__c  = AccList[i].ID;            
        }
    }
    }


 
I have a two lookup field on opportunity object  i want to update lookup1 field if lookup2 (owner) field gets updated but i want this field to update in user mode not in system mode , since my lookup2 field is owner field i want to assign the record owner o only those user who have read access to the record . i tried with trigger and process builder  both are running in system mode.i tried to create with sharing class and call that class in trigger ..but that is also running in systme mode...
can somebody please help me with other ideas
I want to add change owner button on opportunity list view page by using lightning componet  . i am  using below code but  can not see change owner button on my oppoty list page 
({
 doInit : function(component, event, helper) {
        var opportunityId = component.get("v.recordId");
        var action = component.get("c.changeOwnerMethod");
        action.setParams({
           opportunityId : opportunityId
        });
        action.setCallback(this, function(response) {
            if(response.getState() === "SUCCESS") {
                console.log("opportunity Owner Changed To Current login User");
             var rec = response.getReturnValue();
             console.log(rec.OwnerId);
            }
        });
        $A.enqueueAction(action);
        $A.get('e.force:refreshView').fire();
 }
})

<aura:component implements="force:hasRecordId,flexipage:availableForRecordHome,force:lightningQuickAction">
  <aura:attribute name="complete" type="Boolean" default="false" />
    <aura:attribute name="opportunityRecord" type="Object"/>
    <force:recordData mode="EDIT" aura:id="recordLoader"
                      recordId="{!v.recordId}"
                      fields="OpportunityNumber,OwnerId"
                      targetFields="{!v.opportunityRecord}" />
    <aura:if isTrue="{!v.opportunity.OwnerId != $SObjectType.CurrentUser.Id}">
    <aura:if isTrue="{!not(v.complete)}">
        <lightning:input type="toggle" messageToggleActive="" messageToggleInactive="" label="Are you sure to take the ownership on this Opportnity record?" name="input1" onchange="{!c.handleClick}"/>
    </aura:if>

    <aura:if isTrue="{!v.complete}">
        Opportunity is assigned to new Owner. 
    </aura:if>
    </aura:if>
    <aura:if isTrue="{!v.opportunityRecord.OwnerId == $SObjectType.CurrentUser.Id}">
        opportunity is already assigned to owner.
    </aura:if>
</aura:component>
I can see the utton via VF page implmentation but  my requirment is to display this via Lightning componet
Please  find my VF page code
 
<apex:page standardController="Opportunity" recordSetVar="opportunities" extensions="Workaround" showHeader="false"
 lightningStylesheets="true">
<script>
        function showToast() {
            sforce.one.showToast({
                "title": "Success!",
                "message": "{!mySelectedSize} record updated successfully.",
                "type": "success"
            });
        }
    </script>
    
    <apex:form id="muform">
        <apex:pageMessage summary="Selected Collection Size: {!mySelectedSize}" 
            severity="info"
                          id="mupms" />
  <apex:pageBlock >
      <apex:pageBlockSection >
      <apex:inputField value="{!Opportunity.OwnerId}" />
      </apex:pageBlockSection>
    <apex:pageBlockTable value="{!selected}" var="opp">
        <apex:column value="{!opp.Name}"/>    
      </apex:pageBlockTable>
      <apex:commandButton action="{!Save}" value="Save" onclick="showToast();" />
      <apex:commandButton value="Cancel" action="{!cancel}" />
    
    </apex:pageBlock>  
    
    </apex:form>    
</apex:page>
 
public class Workaround {
 ApexPages.StandardSetController setCon;

    public selectedSizeWorkaround(ApexPages.StandardSetController controller) {
        setCon = controller;
    }

    public integer getMySelectedSize() {
                return setCon.getSelected().size();
        }
       
    public integer getMyRecordsSize() {
        return setCon.getRecords().size();
    }

}


 
Hi All,

I have a trigger on provisiong object to create a user record when provising record gets created on page layout i have a field called model if user select model user it should assign the profile from user  and assign it to new user  ...but it not assigning and thoughing a error that profiel id is empty when i am trying to to with query  it is working perfectly but i dont want to user querry here . how can i avoid query here
User M=[Select id,Name,ProfileId, from User where Id =: PR.Model__c];
PR.ProfileId = M.Profile Id///THis is working 

i am trying to avoid a query and writing like this

  usr.ProfileId = PR.User__r.ProfileId; // it is not fetching the profile and thoughing and error.

 
Hi All,

I have a trigger to create a user object when  organization records get created on org page layout we have email field  i created 
CommunityNickname  frmula field in org objet  like below ,i think this  what coming in user object , Now i am not sure how can i make this field unic like if i have a 2 email like test1.user1@gmail.com and test1.user1@yahoo .com ....As per my logic it will allow to save org record but while creating user it is going to though an error.

can i add some logic in formula field or code that if  community nickname is not unic add ++1 or something to make the field unic?
 
LEFT(Email__c ,Find("@", Email__c )-1)

 
have a custom setting called product and under that i created two fields called and other is string field BD__c. i want to display picklist value based on string matching record. my custom setting looks like
AAA |1,2,6,8|| common for all
BBB |1,2,6,8
NNN|8 || only when BD is 8 
CCC| 1,2,6|| only when BD is 1,2,6
public List < SelectOption > getTR_picklistvalue() {
    system.debug('******Start of getTR_picklistvalue');
    List < SelectOption > options = new List < SelectOption > ();
    options.add(new SelectOption('', '--Select--'));
    Map < String, picklistvalue__c > Prod = picklistvalue__c.getAll();
    List < String > keys = new List < String > (Prod.keySet());
    keys.sort();
    for (String key: keys) {
        if (Prod.get(Key).BD__c == '1,2,6,8')
            Options.add(new SelectOption(Prod.get(Key).picklistvalue__c, Prod.get(Key).Name));
        else
            Options.add(new SelectOption(Prod.get(Key).picklistvalue__c, Prod.get(Key).Name));
        //options.sort();
    }
    return options;

}


DDD|1,2,6
so my requirmet is to display AAA BBB CCC and DDD when BD is 1,2 or 6,
and Display NNN,AAA,BBB when  it is 1or 2,6.
so when string value is 1,2,6,8 it should show AAA, BBB when its 8 it should show NNN, but i can see all the values even if BD__c==8
Here is my apex contoller method. can someone suggest me what i am missing Or can someone just help me how to diaply values on controller based on other field value
I stored all my picklis values in custom setting and i am accessing those values in my  controller like  /**for (ApplicationPicklist__c Application : ApplicationPicklist__c.getAll().values())
       options.add(new SelectOption(Application.Application__c ,Application.Name+' - '+Application.Application__c));
        return options;**/

do we have option to set any default value in apex code .and cn i sort the values alphabetically
I am trying to create new testcase record for some case recordtype which is matching particular condition.i configured everything whch is need in the code like recordtype name status ,recordtype id ispriavte in   in my custom setting , now i m trying tocreate a record using trigger .but while creating a record i am geting "Apex trigger NewtestCaseRecord caused an unexpected exception, contact your administrator: NewtestCaseRecord: execution of AfterInsert caused by: System.NullPointerException:  NewCaseRecord: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: ()" can someone please help me to find wht i am missing in my triger
trigger NewTestCaseRecord on Case (after insert,before update, after update) {
    
    if(!UserValidation.ValidationAccess()) {
                system.debug('Chatter_helper.getIstestCaseCreated()' + Chatter_helper.getIstestCaseCreated());
        if (!Chatter_helper.getIstestCaseCreated() ) {
            Map<string,string> caseRecordTypeMap = new Map<string,string>();
            set<string> caseRecordTypeSet = new set<string>();
            string rec_type;
            CaseRecordTypeClass RecordtypeCS = new CaseRecordTypeClass();
            RecordtypeCS.CaseFetchRecordtypes();
            Map<string, test_Settings__c> allRecordTypeMap = CaseRecordTypeClass.CaseRecordtypeMap;
            system.debug('allRecordTypeMap :NewServicenetrecord:' + allRecordTypeMap);
            for(test_Settings__c RT : allRecordTypeMap.values()){
                if(RT.SobjectType__c == 'case'){ 
                    if(RT.Name == 'Request1' || RT.Name == 'req2' || RT.Name == 'req3' || RT.Name == 'req4') {               
                    caseRecordTypeMap.put(RT.Name, RT.RecordtypeId__c.substring(0,15));
                        caseRecordTypeSet.add(RT.RecordtypeId__c.substring(0,15));
                } 
              }
            }
             system.debug('caseRecordTypeMap : ' + caseRecordTypeMap);
            system.debug('caseRecordTypeSet : ' + caseRecordTypeSet);
            
             List<test_Case__c > testCaseList = new List<test_Case__c >();
                        List<Case> caselist = new List<Case>();
            for(Case c: trigger.new){
             rec_type=c.RecordTypeId;
                if( caseRecordTypeSet.contains(rec_type.substring(0,15)) && C.Status == 'CaseRecordType__c.Status__c' && c.AD_Private__c == true)    {              
                   caselist.add(c);
                }
            }
            
           /* for(Case c: trigger.new){
                IF(Case.RecordtypeId = test_Settings__c.RecordtypeId__c){
                 rec_type=c.RecordTypeId;
                //if( caseRecordTypeSet.contains(rec_type.substring(0,15)))    {
                If(C.Status == 'test_Settings__c.Status__c' && c.AD_Private__c == false){
                     test_Case__c testCase = new test_Case__c(); 
                    testCase.Case = Case.ID;
                    testCase.SendEmail = true;
                    testCase.NotificationType = test_Settings__c.NotificationType;
                    testCaseLISt.add(testCase);

                   caselist.add(c);
                }
}
            }*/
        // 
            
                  system.debug('***caselist'+caselist.size());
                if(caselist.size()>0) {
                    for(case c : caselist){
                        rec_type=c.RecordTypeId;
                         test_Settings__c CRT = new test_Settings__c();
                        test_Case__c testCase = new test_Case__c();                       
                      if(CRT.Send_Email_to_OSJ__c == true){
                  rec_type=c.RecordTypeId;               
                testCase.Case__c = c.ID;
                testCase.Send_Email__c = true;
                testCase.Notification_Type__c = CRT.Notification_Type__c;
                testCaseLISt.add(testCase);
                    }
                    else{
                 rec_type=c.RecordTypeId;
                testCase.Case__c = C.ID;
                testCase.Send_Email__c = false;
                testCase.Notification_Type__c = CRT.Notification_Type__c;
                         testCaseLISt.add(testCase);
                    }                       
             
                }
            }

 
I am  using custom metadata would what custom field i should create while using custom metadata? and how i can call in trigger

Here is my requirment...

I am creating caseemail record  for cetain case status and record type ,i have create record for satus and record type combitions. Also after creating a record i need to set on filed case notificatios = some value.

Currently i created  recordtype name, record type id ,status and notification field,but not sure how i can use tis fileds in my code , can you please give me some idea on that.

Thanks in Advance
i wrote a trigger which is use to create a record on case satus update, but now i have to store all record types in custom setting (so that it is easy to add or remove) based on requirment ,can someone please help me to create custom settings ,i am not sure ow to call custom setting under if condition.

Thanks in advance
Hi All,

We wrote one schudle apex to send an outound messgae montlhy, but we are seeing there is 0 messgaes pending for delivy under "Next items for delivery" and "Oldest failures in queue" one thing i see in sechedule class is we are using future method  but we are using this class since long time so it should not be the issue

Developer script exception 'Schedulable' for job id '' : 500 status code return from request to https://rajnilighting-dev-ed.my.salesforce.com/ui/setup/outbound/WfOutboundStatusUi?inline=1&setupid=WorkflowOmStatus Apex script unhandled exception by user/organization:  
Failed to invoke future method 'public static void Callouts()' on class 'HostSchedulable' for job id '---'
 
caused by: System.VisualforceException: 500 status code return from request to https://rajnilighting-dev-ed.my.salesforce.com/ui/setup/outbound/WfOutboundStatusUi?inline=1&setupid=WorkflowOmStatus

Do i need to raise the case with salesforce  or is this somthing we should handle from our side,
Hi All,

I am trying to add External link on account detail page by using inline VF page here is my code for vf page and controller
<apex:page standardController="Account" extensions="inlinecontroller">
 <apex:form >
   <apex:pageBlock title="My Inline Visualforce page">
                  <apex:pageBlockButtons >
                <apex:commandButton action="{!MicroLink4}" value="MicroLink4"/>
//Microlink4 is link i created and embeded extenal link in it
                
            </apex:pageBlockButtons>
               </apex:pageBlock>
 </apex:form>
</apex:page>
 
public with sharing class inlinecontroller {
Public contact conRec{get;set;}
Public id accRecId;
Public account accRec{get;set;}
    public inlinecontroller(ApexPages.StandardController controller) {      
     accRecId = [select id,accountid from contact where id = :ApexPages.currentPage().getParameters().get('id')].accountid;
      if(accRecId != null)
         accRec = [select id,name,accountnumber,annualrevenue from account where id =:accRecId];
    }
}
But not able to acive the same. my requirment is to embed the external link into salesforce possibly by using VF page than need to add into account detail page

Can someone please help me with inline controller code to embed a link . i already implemented the same with web tabs and vf tabs but think is we need external link on account detail page not in the form of tab
error is in <apex:outputPanel rendered="{!IF(finance__c.Income__c >=0,true,false)}"/> in <outputpanel> component .

I am trying to first check null values for the field to void the error,but i am stuck

Previouly  we have <apex:outputPanel rendered="{!IF(finance__c.Income__c >=0,true,false)}">
after that we got a requirment to check first if field value is nulll so i tried   something like
<apex:outputPanel rendered="{!!IsNull(finance__c.Income__c) && finance__c.Income__c > 0}">
$<apex:outputField value="{!finance__c.Income__c}" />
                        </apex:outputPanel> 

The element type "apex:outputpanel" must be terminated by the matching end-tag "</apex:outputpanel>".

i already terminated output panel not sure what i am missing. can someone help me with syntax
first i have to check if value is null and if not than i have to check whether it is greater than or quel to 0 and than i havr to disply the field.

thanks in advace
please help me with the solution
 
I have developed some code for Step 5 in the Superbadge, but appear to stuck as I run the test. I am encountering an error and attempting to determine how to configure my code to pass the test. Are there any steps I am missing? I've covered much of the superbadge, but remain stuck here. 
@isTest
global class WarehouseCalloutServiceMock implements HttpCalloutMock {
    // implement http mock callout
    global HttpResponse respond(HttpRequest request){
        
        System.assertEquals('https://th-superbadge-apex.herokuapp.com/equipment', request.getEndpoint());
        System.assertEquals('GET', request.getMethod());
        
    	// Create a fake response
		HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'application/json');
		response.setBody('[{"_id":"55d66226726b611100aaf741","replacement":false,"quantity":5,"name":"Generator 1000 kW","maintenanceperiod":365,"lifespan":120,"cost":5000,"sku":"100003"}]');
        response.setStatusCode(200);
        return response;
    }
}
@isTest
private class WarehouseCalloutServiceTest {
  // implement your mock callout test here
	@isTest
    static void WarehouseEquipmentSync(){
        Test.startTest();
        // Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new WarehouseCalloutServiceMock()); 
        // This causes a fake response to be sent from the class that implements HttpCalloutMock. 
        WarehouseCalloutService.runWarehouseEquipmentSync();
        Test.stopTest();        
        System.assertEquals(1, [SELECT count() FROM Product2]);        
        
    }
    
}
public with sharing class WarehouseCalloutService {

    private static final String WAREHOUSE_URL = 'https://th-superbadge-apex.herokuapp.com/equipment';
    
    // complete this method to make the callout (using @future) to the
    // REST endpoint and update equipment on hand.
    @future(callout=true)
    public static void runWarehouseEquipmentSync(){
        Http http = new Http();
		HttpRequest request = new HttpRequest();
		request.setEndpoint(WAREHOUSE_URL);
		request.setMethod('GET');
		HttpResponse response = http.send(request);
		// If the request is successful, parse the JSON response.
		if (response.getStatusCode() == 200) {
    		// Deserialize the JSON string into collections of primitive data types.
    		List<Object> equipments = (List<Object>) JSON.deserializeUntyped(response.getBody());
            List<Product2> products = new List<Product2>();
            for(Object o :  equipments){
                Map<String, Object> mapProduct = (Map<String, Object>)o;
                Product2 product = new Product2();
                product.Name = (String)mapProduct.get('name');
                product.Cost__c = (Integer)mapProduct.get('cost');
                product.Current_Inventory__c = (Integer)mapProduct.get('quantity');
                product.Maintenance_Cycle__c = (Integer)mapProduct.get('maintenanceperiod');
                product.Replacement_Part__c = (Boolean)mapProduct.get('replacement');
                product.Lifespan_Months__c = (Integer)mapProduct.get('lifespan');
                product.Warehouse_SKU__c = (String)mapProduct.get('sku');
                product.ProductCode = (String)mapProduct.get('_id');
                products.add(product);
            }
            if(products.size() > 0){
                System.debug(products);
                upsert products;
            }
		}
    }

}

Please Help!



 
I am trying to redirect  to the custom object record page after action in persfored by lightning button
Helper: function(component, event, getInputkeyWord) {
        // call the apex class method 
        var action = component.get("c.Function");// calling a method from aura enable class to persfor a opeation
        // set param to method  
        action.setParams({
            'Records': component.get("v.NextRecords")
        });
        // set a callBack    
        action.setCallback(this, function(response) {

            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                // if storeResponse size is equal 0 ,display No Records Found... message on screen.                }
                if (storeResponse.length == 0) {
                    component.set("v.Message", 'No Records Found...');
                } else {
                    component.set("v.Message", '');
                    // set searchResult list with return value from server.
                }
                component.set("v.UserList", storeResponse);
                alert('operation perfored  Sucessfully'); // showing a message once operation is completed
				/// trying to redirect the page from lightning component page to record detai page
               var navEvent = $A.get("e.force:navigateToSObject");
              navEvent.setParams({
              recordId: component.get("v.objSobject").Id,
              slideDevName: "detail"
         });
         navEvent.fire();

I am getting This page has an error. You might just need to refresh it. Error in $A.getCallback() [Cannot read property 'setParams' of undefined] Callback failed: apex://ETre/AuarApexClass/ACTION$UserFunction Failing descriptor: {markup://c:MultiSelectLookup}
I'm new to developing in general and I am trying to create a trigger that updates the custom lookup field Test1__c and account__c on the custom object test2  object. I have a created a custom object called test2  o  which has a related one-to-one relationship with the Account and test 1. I'm getting an error when attempting to save the Opportunity record, although it mentions the correct reference below but doesnt populate the field. My code is pasted below the error message."Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger Populatetest2caused an unexpected exception, contact your administrator: Populatetest2 : data changed by trigger for field Repcode: data value too large: (value has been hidden)"
 
trigger PopulateTest2 on Test1(before insert,before update) {
    set<ID> setofTest2 = new set<id>();
    set<ID> setofContactUser     = new set<id>();
    for (Test1 CA : trigger.new){
        if(CA.Test2_Name__c != null){
            setofTest2.add(CA.Test2_Name__c);}
        if(CA.ContactUser__c!=null){
            setofContactUser.add(CA.ContactUser__c); }   }       
        List<Test2__c> Test2List  = [Select ContactUser__c from Test2__c where id in: setofTest2];
        List<Account>  AccList = [Select Name from Account where id in: setofContactUser];    
     for(Integer i = 0; i < Trigger.new.size(); i++){
        if (Trigger.new[i].Test2__c != null) {
           Trigger.new[i].Test2__c = Test2List[i].ID;            
        }
        if (Trigger.new[i].ContactUser__c != null) {
           Trigger.new[i].ContactUser__c  = AccList[i].ID;            
        }
    }
    }


 
I want to add change owner button on opportunity list view page by using lightning componet  . i am  using below code but  can not see change owner button on my oppoty list page 
({
 doInit : function(component, event, helper) {
        var opportunityId = component.get("v.recordId");
        var action = component.get("c.changeOwnerMethod");
        action.setParams({
           opportunityId : opportunityId
        });
        action.setCallback(this, function(response) {
            if(response.getState() === "SUCCESS") {
                console.log("opportunity Owner Changed To Current login User");
             var rec = response.getReturnValue();
             console.log(rec.OwnerId);
            }
        });
        $A.enqueueAction(action);
        $A.get('e.force:refreshView').fire();
 }
})

<aura:component implements="force:hasRecordId,flexipage:availableForRecordHome,force:lightningQuickAction">
  <aura:attribute name="complete" type="Boolean" default="false" />
    <aura:attribute name="opportunityRecord" type="Object"/>
    <force:recordData mode="EDIT" aura:id="recordLoader"
                      recordId="{!v.recordId}"
                      fields="OpportunityNumber,OwnerId"
                      targetFields="{!v.opportunityRecord}" />
    <aura:if isTrue="{!v.opportunity.OwnerId != $SObjectType.CurrentUser.Id}">
    <aura:if isTrue="{!not(v.complete)}">
        <lightning:input type="toggle" messageToggleActive="" messageToggleInactive="" label="Are you sure to take the ownership on this Opportnity record?" name="input1" onchange="{!c.handleClick}"/>
    </aura:if>

    <aura:if isTrue="{!v.complete}">
        Opportunity is assigned to new Owner. 
    </aura:if>
    </aura:if>
    <aura:if isTrue="{!v.opportunityRecord.OwnerId == $SObjectType.CurrentUser.Id}">
        opportunity is already assigned to owner.
    </aura:if>
</aura:component>
I can see the utton via VF page implmentation but  my requirment is to display this via Lightning componet
Please  find my VF page code
 
<apex:page standardController="Opportunity" recordSetVar="opportunities" extensions="Workaround" showHeader="false"
 lightningStylesheets="true">
<script>
        function showToast() {
            sforce.one.showToast({
                "title": "Success!",
                "message": "{!mySelectedSize} record updated successfully.",
                "type": "success"
            });
        }
    </script>
    
    <apex:form id="muform">
        <apex:pageMessage summary="Selected Collection Size: {!mySelectedSize}" 
            severity="info"
                          id="mupms" />
  <apex:pageBlock >
      <apex:pageBlockSection >
      <apex:inputField value="{!Opportunity.OwnerId}" />
      </apex:pageBlockSection>
    <apex:pageBlockTable value="{!selected}" var="opp">
        <apex:column value="{!opp.Name}"/>    
      </apex:pageBlockTable>
      <apex:commandButton action="{!Save}" value="Save" onclick="showToast();" />
      <apex:commandButton value="Cancel" action="{!cancel}" />
    
    </apex:pageBlock>  
    
    </apex:form>    
</apex:page>
 
public class Workaround {
 ApexPages.StandardSetController setCon;

    public selectedSizeWorkaround(ApexPages.StandardSetController controller) {
        setCon = controller;
    }

    public integer getMySelectedSize() {
                return setCon.getSelected().size();
        }
       
    public integer getMyRecordsSize() {
        return setCon.getRecords().size();
    }

}


 
Hi All,

I have a trigger to create a user object when  organization records get created on org page layout we have email field  i created 
CommunityNickname  frmula field in org objet  like below ,i think this  what coming in user object , Now i am not sure how can i make this field unic like if i have a 2 email like test1.user1@gmail.com and test1.user1@yahoo .com ....As per my logic it will allow to save org record but while creating user it is going to though an error.

can i add some logic in formula field or code that if  community nickname is not unic add ++1 or something to make the field unic?
 
LEFT(Email__c ,Find("@", Email__c )-1)

 
i wrote a trigger which is use to create a record on case satus update, but now i have to store all record types in custom setting (so that it is easy to add or remove) based on requirment ,can someone please help me to create custom settings ,i am not sure ow to call custom setting under if condition.

Thanks in advance
error is in <apex:outputPanel rendered="{!IF(finance__c.Income__c >=0,true,false)}"/> in <outputpanel> component .

I am trying to first check null values for the field to void the error,but i am stuck

1. first not sure whether we can check two if condition in output panel
2. <apex:outputText value=" to " rendered="{!IF(ISBLANK(finance__c.Income__c) , false , true)}" adding this line before  <apex:outputPanel rendered="{!IF(finance__c.Income__c >=0,true,false)}"/> but no luck

please help me with the solution
 
error is in <apex:outputPanel rendered="{!IF(finance__c.Income__c >=0,true,false)}"/> in <outputpanel> component .

I am trying to first check null values for the field to void the error,but i am stuck

1. first not sure whether we can check two if condition in output panel
2. <apex:outputText value=" to " rendered="{!IF(ISBLANK(finance__c.Income__c) , false , true)}" adding this line before  <apex:outputPanel rendered="{!IF(finance__c.Income__c >=0,true,false)}"/> but no luck

please help me with the solution

 
i wrote a validation on user to restrict email address length up to 50 characters and it is working good , but challenged is to fix any records already having a email address of more than 50 characters...as it is lenght restriction so i dont think data loader will work .looking for feasible solution.i know validation is only applied on already existing record ,but is there any possible way to update those email address or if we can send the email to user that email is no longer valid please update email lenght under 50 .
@isTest
private class optytst
{
    static testMethod void optytstpositive()
    {
        TestHelper.createCustomSettings();
        
        Map<String, Id> optyRTMap = RecordTypeUtilities.getRTMap('Opportunity');
        
        List<OpportunityLineItem> oliList = new List<OpportunityLineItem>();
        
        Id solId = Testfactory.createSolution('Test',
                                                  'Corporate Shared',
                                                  'Corporate',
                                                  'Mark Griffin',
                                                  'Larry Graubner');
                                                  
        Id prodId = Testfactory.createProduct('Claims',
                                                  'e-Services',
                                                  solId,
                                                  'Claims',
                                                  'e-Services Deafult');
                                                  
        Id pbId = Testfactory.createPricebook('Provider Complete');
        
        Id beId = Testfactory.createPricebookEntry(prodId,
                                                        pbId);
                   
        Datetime timeStamp = Datetime.now();
        Date closeDate = Date.today();
        
        Account acct = new Account();

        acct.Name = 'test Unit Test Account';
        acct.Type = 'Provider';
        acct.Federal_Tax_ID__c = '999887777';
        acct.Integration_Id__c = 'SF_A99999999999';
        acct.BillingStreet = '3055 Lebanon Pike';
        acct.BillingCity = 'ville';
        acct.BillingState = 'TN';
        acct.BillingPostalCode = '37214';
        insert acct;
        
        Contact con = new Contact();
        con.LastName = 'Test';
        con.Title = 'VP';
        con.AccountId = acct.Id;
        con.Email = 'rater@sfdc.com';
        insert con;
        
        Campaign cmpn = new Campaign();
        
        cmpn.Name = 'test Unit Test Campaign';
        insert cmpn;
        
        Opportunity opty = new Opportunity();
        
        opty.RecordTypeId = optyRTMap.get('Provider Complete');
        opty.Name = 'test Test Opty 1';
        opty.AccountId = acct.Id;
        opty.CloseDate = closeDate;
        opty.StageName = '00 - Lead/Target';
        opty.CampaignId = cmpn.Id;
        opty.LeadSource = 'Self Generated Lead';
        opty.Reason_Won_Lost__c = 'Other';
        opty.Existing_Provider_Count__c = 10;
        opty.Incentive__c = 'Retail Price Break';
        opty.Incentive_Description__c = 'Test description';
        opty.Live_Date__c = closeDate;
        opty.Proposal_Expiration_Date__c = closeDate;
        opty.Incentive_Providers__c = 10;
        opty.Incentive_Deadline__c = closeDate;
        insert opty;
        
        OpportunityContactRole conRole = new OpportunityContactRole();
        conRole.ContactId = con.Id;
        conRole.OpportunityId = opty.Id;
        conRole.Role = 'Executive';
        insert conRole;
        
        OpportunityLineItem oli = new OpportunityLineItem();
        oli.OpportunityId = opty.Id;
        oli.PricebookEntryId = beId;
        oli.Quantity = 1;
        oli.Sales_Type__c = 'New';
        oli.Revenue_Type__c = 'Strategic';
        oli.TotalPrice = 1000;
        oliList.add(oli);
        
        OpportunityLineItem oli2 = new OpportunityLineItem();
        oli2.OpportunityId = opty.Id;
        oli2.PricebookEntryId = beId;
        oli2.Quantity = 1;
        oli2.Sales_Type__c = 'New';
        oli2.Revenue_Type__c = 'Strategic';
        oli2.TotalPrice = 1000;

        oli2.Project_Id__c = '1-234567890';
        oliList.add(oli2);
        
        insert oliList;
       // set<ID> ids =  Trigger.newMap.keyset();      
        PricebookEntry be = [SELECT    Id,
                                        IsActive
                              FROM      PricebookEntry
                              WHERE     Id = :beId];

        be.IsActive = false;
        update be;
        
        try
        {
            delete oli;
        }
        catch (System.Dmlexception e)
        {
            System.assert(e.getMessage().contains('An Opportunity must have a product before it can be moved'),e.getMessage());
        }
        
        opty.Incentive__c = 'Other';
        try
        {
            update opty;
        }
        catch (System.Dmlexception e)
        {
            System.assert(e.getMessage().contains('Incentive Description is required if Incentive = Other'),e.getMessage());
        }
        
        opty.StageName = '05 - Win';
        
        try
        {
            update opty;
        }
        catch(System.Dmlexception e)
        {
            System.assert(e.getMessage().contains('is not an active product for pricebook.'),e.getMessage());
        }
        
        be.IsActive = true;
        update be;
        
        opty.Incentive__c = 'Retail Price Break';
        opty.StageName = '05 - Win';
        opty.Competitor__c = 'mc';
        
        update opty;

        try
        {
            delete oli2;
        }
        catch (System.Dmlexception e)
        {
            System.assert(e.getMessage().contains('Cannot delete Opportunity Products that are in the implementation phase.'),e.getMessage());
        }
    }
    
    static testMethod void optyTestNegative()
    {
        TestHelper.createCustomSettings();
        
        Map<String, Id> optyRTMap = RecordTypeUtilities.getRTMap('Opportunity');
        
        Datetime timeStamp = Datetime.now();
        Date closeDate = Date.today();
        
        Campaign cmpn = new Campaign();
        
        cmpn.Name = 'test Unit Test Campaign';
        insert cmpn;
        
        Account acct = new Account();

        acct.Name = 'test Unit Test Account';
        acct.Type = 'Provider';
        acct.Federal_Tax_ID__c = '999887777';
        acct.Integration_Id__c = 'SF_A99999999999';
        acct.BillingStreet = '3055 Lebanon Pike';
        acct.BillingCity = 'ville';
        acct.BillingState = 'TN';
        acct.BillingPostalCode = '37214';
        insert acct;
        
        Opportunity opty2 = new Opportunity();
        
        opty2.RecordTypeId = optyRTMap.get('Provider Complete');
        opty2.Name = 'test Test Opty 1';
        opty2.AccountId = acct.Id;
        opty2.CloseDate = closeDate;
        opty2.StageName = '00 - Lead/Target';
        opty2.CampaignId = cmpn.Id;
        opty2.LeadSource = 'Self Generated Lead';
        opty2.Reason_Won_Lost__c = 'Other';
        opty2.Existing_Provider_Count__c = 10;
        opty2.Incentive__c = 'Retail Price Break';
        opty2.Incentive_Description__c = 'Test description';
        opty2.Live_Date__c = closeDate;
        opty2.Proposal_Expiration_Date__c = closeDate;
        opty2.Incentive_Providers__c = 10;
        opty2.Incentive_Deadline__c = closeDate;
        
        try
        {
            insert opty2;           
        }
        catch (System.Dmlexception e)
        {
            System.assert(e.getMessage().contains('Duplicate Opportunity names by Account are not allowed.'),e.getMessage());
        }
        
        Opportunity opty3 = new Opportunity();
        
        opty3.RecordTypeId = optyRTMap.get('Provider Complete');
        opty3.Name = 'test Test Opty 2';
        opty3.AccountId = acct.Id;
        opty3.CloseDate = closeDate;
        opty3.StageName = '00 - Lead/Target';
        opty3.CampaignId = cmpn.Id;
        opty3.LeadSource = 'Self Generated Lead';
        opty3.Reason_Won_Lost__c = 'Other';
        opty3.Existing_Provider_Count__c = 10;
        opty3.Incentive__c = 'Retail Price Break';
        opty3.Incentive_Description__c = 'Test description';
        opty3.Live_Date__c = closeDate;
        opty3.Proposal_Expiration_Date__c = closeDate;
        opty3.Incentive_Providers__c = 10;
        opty3.Incentive_Deadline__c = closeDate;
        insert opty3;
        
        opty3.Name = 'test Test Opty 1';

        try
        {
            update opty3;           
        }
        catch (System.Dmlexception e)
        {
            System.assert(e.getMessage().contains('Duplicate Opportunity names by Account are not allowed.'),e.getMessage());
        }
        
        Opportunity opty4 = new Opportunity();
        
        opty4.RecordTypeId = optyRTMap.get('Provider Complete');
        opty4.Name = 'test Test Opty 3';
        opty4.AccountId = acct.Id;
        opty4.CloseDate = closeDate;
        opty4.StageName = '05 - Win';
        opty4.CampaignId = cmpn.Id;
        opty4.LeadSource = 'Self Generated Lead';
        opty4.Reason_Won_Lost__c = 'Other';
        opty4.Existing_Provider_Count__c = 10;
        opty4.Incentive__c = 'Retail Price Break';
        opty4.Incentive_Description__c = 'Test description';
        opty4.Live_Date__c = closeDate;
        opty4.Proposal_Expiration_Date__c = closeDate;
        opty4.Incentive_Providers__c = 10;
        opty4.Incentive_Deadline__c = closeDate;
        
        try
        {
            insert opty4;           
        }
        catch (System.Dmlexception e)
        {
            System.assert(e.getMessage().contains('Closing Stage not allowed at Opportunity creation. ' + 
                                                  'You must update the stage after a product is added. ' +
                                                  '(PreventNewClosingOptyBI.trigger)'),e.getMessage());
        }
    }
    
    static testMethod void testThresholdHandler()
    { 
        Set<String> statuses   = new set<String>{'Open', 'Responded', 'Reparation'};
        Set<String> priorities = new set<String>{'SLA 1', 'SLA 2', 'SLA 3'};
        Set<String> origins    = new set<String>{'Email', 'Web', 'Phone'};
    
        for (String p : priorities) 
            for (String o : origins) 
                for (String s : statuses) 
                    CaseSLAThresholdHandler.getThresholds(new Case(Priority=p, Origin=o, Status=s));
                    
        // Test unknown case.
        CaseSLAThresholdHandler.getThresholds(new Case(Priority='Hi', Origin='Hi', Status='Hi'));
                
    }
    
    static testMethod void testTrigger()
    {
        Case c = new Case(Priority='SLA 1', Origin='Web', Status='Responded');
        insert c;
        
        c.Status = 'Open';
        update c;
        
        c.Priority = 'SLA 4';
        update c;
    }
    
    static testMethod void testSLAController()
    { 
        Case c = new Case(Priority='SLA 1', Origin='Web', Status='Responded', Last_Status_Change__c=System.now());
        insert c;
        
        ApexPages.StandardController caseController = new ApexPages.StandardController(c);
        CaseSLAController slaController = new CaseSLAController(caseController);
        
        slaController.getIsWithin();
        slaController.getDuration();
        slaController.getSlaUrl();
    }
    
    static testMethod void testSLAListController()
    { 
        List<Case> cList = new List<Case>(); 
        
        cList.add(new Case(Priority='SLA 1', Origin='Web', Status='Responded', Last_Status_Change__c=System.now()));
        cList.add(new Case(Priority='SLA 1', Origin='Web', Status='Open'));
        cList.add(new Case(Priority='SLA 1', Origin='Web', Status='Open'));
        cList.add(new Case(Priority='SLA 1', Origin='Web', Status='Open'));
        insert cList;
        
        cList[1].Last_Status_Change__c = System.now().addSeconds(-120);
        cList[2].Last_Status_Change__c = System.now().addSeconds(-90);
        update cList;
        
        CaseSLAListController slaListController = new CaseSLAListController();
        slaListController.getIsWithin();
    }
    
    









here is the quick background:- i wrote a validation rule to restrict the picklist value on user object but there is losts of test claases are getting failed. i choose teh approach to create a helper class to create user test data then i can call. i tried to write the test class not sure it will work please help me with the good approach . how can i can mmy helper class into my test class
global class TestClassHelper
{    
     public User CreateUser()
    {
        //Get a profile id from the data base to assign to our user in this case make them a sys admin
        Profile p = [select id from profile where name='System Administrator'];
           
           //Create a new sys admin user and do an insert  
        User u = new User(alias = 'standt', email='noEmail@testorg.com',
                          emailencodingkey='UTF-8', lastname='Testo', languagelocalekey='en_US', localesidkey='en_US', profileid = p.Id,
                          timezonesidkey='America/Los_Angeles', username='MrTestUser@testorg.com',Resource_Type__c='Employee');
                          
        User u1 = [Select u.Profile.Name, u.ProfileId, u.Name, u.Id From User u where u.Profile.Name = 'System Administrator' limit 1];
                          
        return u;
    }
    
    public User CreateUser(string userType)
    {
        //Get a profil id from the data base to assign to our user in this case make them a sys admin
        Profile p = [select id from profile where name=:userType];
           
           //Create a new sys admin user and do an insert  
        User ur = new User(alias = 'standt', email='noEmail@testorg.com',
                          emailencodingkey='UTF-8', lastname='Testo', languagelocalekey='en_US', localesidkey='en_US', profileid = p.Id,
                          timezonesidkey='America/Los_Angeles', username='MrTestUser@testorg.com',Resource_Type__c='Employee');
           return ur;
    }
}
I wrote the validation rule on user object for picklist field value should be A, B,C. now my test classes are getting failed.can i just add one line user.picklist__c = 'A", before user record get an insert or i need to add a line for each picklist value.i.e user.picklist__c = 'A"user.picklist__c = 'B"user.picklist__c = 'C"
 

I am creating a custom clone button. If user is trying to clone a record which has record type for which he does not have access, i want dont want to pass record type id to url.

 

Please let me know how can we check in javascript if user has access to particular record type.