• Shruti Nigam
  • NEWBIE
  • 70 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 42
    Questions
  • 10
    Replies
Hi all,

I hade created one HTMlL table and i need to add line item field in that anyone know how to do that..???
Here is the apex class for which I want to write test class:-
public class TestController {
    /**
     * Returns JSON of list of ResultWrapper to Lex Components
     * @object - Name of SObject
     * @API_Text - API name of field to display to user while searching
     * @API_Val - API name of field to be returned by Lookup COmponent
     * @limit  - Total number of record to be returned
     * @API_Search - API name of field to be searched
     * @search - text to be searched
     * */
    @AuraEnabled(cacheable=true) 
    public static String searchDatabase(String object, String API_Text, String API_Val, 
                                  Integer limit,String API_Search,String search ){
        
        search='\'%' + String.escapeSingleQuotes(searchText.trim()) + '%\'';

        
        String query1 = 'SELECT '+API_Text+//' ,'+API_Val+
                        ' FROM '+object+
                            ' WHERE '+API_Search+' LIKE '+search+ 
                        ' LIMIT '+limit;
        
        List<sObject> sobjList1 = Database.query(query1);
        List<ResponseWrapper> ret = new List<ResponseWrapper>();
        
        for(SObject s : sobjList){
            ResponseWrapper obj = new ResponseWrapper();
            obj.objName = object;
            obj.text = String.valueOf(s.get(API_Text)) ;
            obj.val = String.valueOf(s.get(API_Text))  ;
            ret.add(obj);
        } 
         return JSON.serialize(ret) ;
    }   
  
Hi i am trying to create user using method Site.createExternalUser(user, accountId, password) in trigger but whenever i try to run the code everytime i get the error That operation is only allowed  from within an active site  anyone know workaround for this.


 
Hi all,

I am using sforce.connection.query() is not working for some of the custom objects any one know what is the issue..???
Hi all,

I am having one object Interview in which I have lookup with Contact and in Contact, there are two record types: Candidate and Interviewer 
So the scenario is whenever I create Interview There are two fields Candidate and Interviewer when I fill it too then the email should go to the email filled in candidate and Interviewer in the contact object 

Can Anyone please help me with the above scenario??
Hi all,
 I'm having two record types in contact object named as Candidate and Interviewer. In that, I want to display two different vf page to the respective record types
Can anyone please help me with the above question?
Hi all need help in writing test class.

Not able to get coverage for both @aura enabled methods.
public class CallPageApexLightning {
	
    public Settings settings;
    public Data data;
    
    @auraEnabled
    public static Map<String, Object> checkuser()
    {
			String email = UserInfo.getUserEmail();

        	Http http = new Http();
			HttpRequest request = new HttpRequest();
			request.setEndpoint('https://xxxxxxxxxxxxx');
			request.setMethod('GET');

			HttpResponse response = http.send(request);
        	Map<String, Object> records;
			if (response.getStatusCode() == 200) 
        	{	
            		Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
                    records = (Map<String, Object>) results.get('data');
   			}

        	String token = String.valueof(records.get('ws_token'));

            Http http1 = new Http();
            HttpRequest request1 = new HttpRequest();

            request1.setEndpoint('https://xxxxxxxxxxxxxxxxxxxxxxx');
            request1.setMethod('POST');
         	request1.setHeader( 'Content-Type', 'application/json' );
        	String JSONContent = '{"email":"'+email+'","ws_token":"'+token+'"}';
        	request1.setBody(JSONContent);

            HttpResponse response1 = http1.send(request1);
        	Map<String, Object> urlrecorddata;
        	Map<String, Object> expertdetail;
            if (response1.getStatusCode() == 200) 
            {
                Map<String, Object> results1 = (Map<String, Object>) JSON.deserializeUntyped(response1.getBody());
                urlrecorddata = (Map<String, Object>) results1.get('data');
            }
        	urlrecorddata.put('ws_token', token);

			return urlrecorddata;        
    }

    @auraEnabled
    public static void closecallapex(String caseid, String experttoken, String token)
    {
        	Http http = new Http();
            HttpRequest request = new HttpRequest();

            request.setEndpoint('https://xxxxxxxxxxxxx');
            request.setMethod('POST');
         	request.setHeader( 'Content-Type', 'application/json' );
        	String JSONContent = '{"cr_id":"'+caseid+'","expert":"'+experttoken+'","ws_token":"'+token+'"}';
        	request.setBody(JSONContent);
        	
            HttpResponse response = http.send(request);
            if (response.getStatusCode() == 200) 
            {
             	CallPageApexLightning ab = CallPageApexLightning.parse(response.getBody());

                afRecord__c cobject = new afRecord__c();
                for(CallPageApexLightning.Call_detail pol:  ab.data.c_detail)
                {
                    	
                        cobject.Case_Related_To__c = caseid;
                        cobject.Expert_Chat__c = pol.expert_chat;
                        cobject.Expert_Notes__c = pol.expert_notes;
                }
                insert cobject;
            }
    }


	public class c_detail {
		public String expert_notes;
		public String expert_chat;
	}

	public class Data {
		public List<Call_detail> c_detail;

	}

	public class Settings {
		public String success;
		public String message;
		public List<String> fields;
	}

    public static CallPageApexLightning parse(String json) 
    {
        return (CallPageApexLightning) System.JSON.deserialize(json, CallPageApexLightning.class);
    }
}

Thanks in advance.
 
Hi all i need to create a record from json response
 
Http http = new Http();
            HttpRequest request = new HttpRequest();

            request.setEndpoint('xxxxxxxxxxxx');
            request.setMethod('POST');
         	request.setHeader( 'Content-Type', 'application/json' );
        	String JSONContent = 'xxxxxxxx';
        	request.setBody(JSONContent);
        	
            HttpResponse response = http.send(request);
        	
            if (response.getStatusCode() == 200) 
            {
                
              System.debug(response.getBody());
            }

The response i am getting is like this
 
-{
"settings" : -{
"success" : 1,
"message" : Call report return successfully. ,
"fields" : -[
call_report_id,
call_duration,
call_started_at,
call_end_at,
call_status,
call_case_id,
expert_notes,
expert_chat,
call_media_url,
call_media_status
]
},
"data" : -{
"call_detail" : -[
-{
"call_report_id" : 505usUAAQ,
"call_duration" : 00:00:03,
"call_started_at" : 2020-02-27 17:59:29,
"call_end_at" : ,
"call_status" : Waiting,
"call_case_id" : jklfgdjdklgjkldgjkldgjf,
"expert_notes" : ,
"expert_chat" : 
}
],
"call_medial" : -[
-{
"call_media_url" : ,
"call_media_status" : Pending
}
]
}
}
 i need to create a single record from above the response in a custom object.
for call_detail  and call_medial fields


Thanks in advance
Hi all,

I need to embed external webiste in vf page and also in lightning component using iframe. So do i need to disbale "Enable clickjack protection for non-Setup Salesforce pages"  cgeckbox  in salesforce.

Thanks in advance
Hi ,
 I need help in json.
When i try to create record using json i am getting error in $User.Id
[
	{
		"attributes": {
			"type": "Activity_Template__c"
		},
		"Name": "Expense test",
		"Assigned_To__c": $User.Id,
	}
]

I want to dynmically set the Assigned_To__c i.e whoever runs this json Assigned_To__c will contain there user id.

Thanks in advance
Hi all,

Anyone know how to add meta tag in aura component ?

Thanks in advance
Hi All,

I am using tessract.js for converting images to text but it is giving error in lightning component.


I have also tried to use as a static resource but it is still giving error.

Anyone know how to convert images to text in lightning component.
Below is my code.

Component
<aura:component implements="lightning:actionOverride,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global">


    <ltng:require scripts="https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js"/>
    
    
    
    
    <lightning:layout>
        <lightning:layoutItem padding="around-small" size ="12">
            <div aria-labelledby="newexpenseform">

                <fieldset class="slds-box slds-theme--default background" size ="12">
					
                  
                    <div class="slds-align_absolute-center slds-p-top_x-large">

                        <lightning:input type="file" 
                                         aura:id="file" 
                                         variant="label-inline" 
                                         name="file" 
                                         onchange="{!c.hulk }"/>  
                    </div>

                   
                    
                    
                </fieldset>
            </div>
        </lightning:layoutItem>
    </lightning:layout>
</aura:component>

Controller
({
	 hulk: function (component, event,helper) 
    {
         var files = event.getSource().get("v.files");
         alert(files);


         console.log(files);
		
         Tesseract.recognize(files).then(function(result)
         {
             console.log(result.text);
             alert(result.text);
         });
  		
        $A.enqueueAction(action);
	}
})

Thanks in advance
 
What are the features available in Salesforce CPQ that are not available on Salesforce?
Why to use Salesforce CPQ and not Salesforce CRM?
If we can create salesforce cpq manually then why to use salesforce cpq in salesforce.
Hi all,

I had saved video in attachment obect and i want to display that video in vf page anyone know how to do it ?
Hi all,

I need to add page number from specific page  in the pdf page.
Thanks in advance
Hi all,

I need to add gif in the pdf page.
I tried to add but it is not working anyone know what is the issue ?

Thanks in advance
Hi all,

I had created ligtning button in uising lightning:button and i want to show error on it.
Anyone know how to do it?

I tried this but it dosen't work
var op = component.find("button1");
op.set("v.errors", [{message:"Select any one option"}]);

Thanks in advance
Hello Everyone I need to create dependent radiobutton just like dependent picklist using flow builder  Can anyone help me out??
Hi all,
I have created a batch class but still i am getting error "First error: Too many Email Invocations: 11" .

Can anyone solve this issue.
Below is my batch class.
global class batchexpense implements Database.Batchable<sObject> {
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
       String query = 'Select Name_of_Employee__c from Expense_Management__c where CreatedDate = LAST_N_DAYS:15';
       return Database.getQueryLocator(query);
     }
    
	global void execute(Database.BatchableContext BC, List<Expense_Management__c> scope){
   		Set<String> myset = new Set<String>();
		for(Expense_Management__c aa : scope)
		{
  			myset.add(aa.Name_of_Employee__c);  
		}    
				
		
   		 for(Expense_Management__c cc : [select id,Name_of_Employee__r.email,Name_of_Employee__c from Expense_Management__c WHERE Name_of_Employee__c =: myset ])
        {
         
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
			Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.ExpenseReport;
            pref.getParameters().put('Id',cc.Name_of_Employee__c );
            pref.setRedirect(true);
             Blob b;
             if(Test.isRunningTest()) { 
                b = blob.valueOf('Unit.Test');
            } else {
                b = pref.getContent();
            }
            attach.setFileName('Expense.pdf');
            attach.setBody(b);
            semail.setSubject('Expense details');
            semail.setSaveAsActivity(true);
         
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
            semail.setWhatId(cc.Id);
     
            
            List<String> sendTo = new List<String>();//to string
           	sendTo.add(cc.Name_of_Employee__r.email);
            semail.setToAddresses(sendTo);
           
            mails.add(semail);
            String emailBody =' <html><body><p> Dear  ,<br><br> Please find the attached Expense details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
     }
    
    	global void finish(Database.BatchableContext BC){
        
    	}
}

Thanks in advance
Field NameField TypeDescription
Previous OwnerLookup (User)The prior sales rep assigned to this Account
New OwnerLookup (User)The new sales rep assigned to this Account
Previous TerritoryLookup (Territory__c)The matching Territory__c record for the prior zip code
New TerritoryLookup (Territory__c)The matching Territory__c record for the new zip code
AccountMaster-Detail (Account)The related Account record
Changed ByLookup (User)The user who changed the BillingPostalCode
Hi ,
 I need help in json.
When i try to create record using json i am getting error in $User.Id
[
	{
		"attributes": {
			"type": "Activity_Template__c"
		},
		"Name": "Expense test",
		"Assigned_To__c": $User.Id,
	}
]

I want to dynmically set the Assigned_To__c i.e whoever runs this json Assigned_To__c will contain there user id.

Thanks in advance
What are the features available in Salesforce CPQ that are not available on Salesforce?
Why to use Salesforce CPQ and not Salesforce CRM?
If we can create salesforce cpq manually then why to use salesforce cpq in salesforce.
Hi all,

I need to add gif in the pdf page.
I tried to add but it is not working anyone know what is the issue ?

Thanks in advance
Hi all,
I have created lightning home page using lightning app builder and placed it on a app.

When i click on a tab it showing error.
"Unfortunately, there was a problem. Please try again. If the problem continues, get in touch with your administrator with the error ID shown here and any other related details. Error ID: 2036862306-1598 (-965828326)"


Anyone know why i am facing this issue..??
Thanks in advance.
trigger OrderTrigger on Order_Line_Item__c (before delete, before update) {
    Set<Id> orderIdSet=new Set<Id>();
    
    for(Order_Line_Item__c ord:Trigger.new)
        orderIdSet.add(ord.Order__c);
    
    Map<String,Boolean> orderMap= new Map<String,Boolean>();
    
    for(Order__c ord:[Select Id,Locked__c from Order__c where Id in :orderIdSet])
        orderMap.put(ord.Id,ord.Locked__c);
    
    for(Order_Line_Item__c ord:Trigger.new)
        if(orderMap.get(ord.Order__c))
        ord.addError('Master Record is Locked. Details cannot be created, edited, or deleted.');
}

Trigger to locked child record based on checkbox "Locked__c" present in Parent object
Hello I want to know to how to send and email notification in the particular scenario where I have create one object in which there are two fields previous owner and new Owner and the situation is that when inm updating account billing postal code Im getting previous owner the one before updating and in new owner im getting value after updating
and now I want to send email notification to both new Owner and Previous Owner telling them there respective place
Previous and new Owner are having static value stored in Users in salesforce
Can anyone help me in this scenario??
Field NameField TypeDescription
Previous OwnerLookup (User)The prior sales rep assigned to this Account
New OwnerLookup (User)The new sales rep assigned to this Account
Previous TerritoryLookup (Territory__c)The matching Territory__c record for the prior zip code
New TerritoryLookup (Territory__c)The matching Territory__c record for the new zip code
AccountMaster-Detail (Account)The related Account record
Changed ByLookup (User)The user who changed the BillingPostalCode