• shekhar 46
  • NEWBIE
  • 110 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 18
    Replies
custom object : policy, fields( Policy Number,Agent(lookup to user),Policy Type - picklist (Personal,Business), Start Date, End Date),
Private access to policy in OWD, So that only owner can see the records,
When policy is created with policy type as business it should share record to agent selected in agent field.-> Use apex 
how to decide fror updating record when to use flow or use trigger 
On account we have total open count field, on contact we have status field of picklis LOVs as open/progress/completed. whenever contact is created /updated with status open, we need to maintain count of open contact on related parent account.
  1. On both account & contact we have role field which is multiselect picklist, having value as  a, b, c, d .  When ever any contact is created/updated  with role value ,  we need to maintain unique role on related parent account of contact. Means  have created account, at that time the role field of account is blank,after that we created 3 contact with role value like ab, bc, cd. Unique value in these three is a.b.c value and these value will be updated on parent.and d will be removed.  write a trigger for thsi condition
what is direction of flow in lwc
Whenever u are updating account object , find the number of contact which are present on account itself.show that count on account object
why cant we write validation rule on deleting record
how to bypass validation rule for set of users
Write a trigger whenever account created, no contact is associated to that account, create dummy contact with contact name as account name. need to check no contact is associated with it and then create dummy contact
which lightning interfce is used to make component avaible for all features
where does the custom setting & custom metadata stored so that we can access them
can we fire validation rule when only record is inserted &  not on record updated?
i want to insert new record in custom object guest_master__c name & email in lwc
in lwc want input text name & email, on clicking button save, want to insert that data into custom object Guest_master__C as new record.
 
I want to create a LWC form for guest to fill the data. 
first name, phone, email, number of guest, DOB, prefered hotel(3star, 4star. 5 star)
card number, expiry month, expiry year, CVV
on save button all get save to database. on saving email to guest email need to send with all above details.

i have written code just to take input , but how to incoorapiorate all other requirement, also how to add picklist field,

html code
<template>
<lightning-card title="guest info">
<lightning-input type="text" label="Enter name"></lightning-input>
<lightning-input type="number" label="Enter Phone number"></lightning-input>
<lightning-input type="text" label="Enter email"></lightning-input>
<lightning-input type="number" label="Enter number of guest"></lightning-input>
<lightning-input type="picklist" label="prefereed hotel type"></lightning-input>
<lightning-input type="date" label="Enter check in date"></lightning-input>
<lightning-input type="date" label="Enter check out date"></lightning-input>

</template>

JS--------------
import {lightning element} from 'lwc';
export default class guestForm extends LightningElement{
}
 
i want to create field for expiry month for card & another field for expiry year of card , which data type shall i use 
in VFP inputtext is empty , then i want to disable the send button .
if inputfield is entered then only user can able to click teh send button
I want to share the inputdata takenn on vfp on send mail to ceo button, reset button & generate pdf button on vfp.
--
< apex:page controller="VendorRegClass" renderAs="{!render}" id="rer" >
< apex:form >
<apex:pageBlock title="VendorRegistrationForm">
<apex:Outputlabel value="Vendor company nname"/>
<apex:inputText value="{!VendorCompanyName}"/>
<apex:Outputlabel value="Vendor contact person"/>
<apex:inputText value="{!VendorContactPerson}"/>
<apex:Outputlabel value="Amount per event"/>
<apex:inputText value="{!AmountPerEvent}"/>
<apex:Outputlabel value="City"/>
<apex:inputText value="{!City}"/>
<apex:Outputlabel value="Country"/>
<apex:inputText value="{!country}"/>
<apex:PageBLockButtons>
<apex:commandButton value="Send" action="{!Send}"/>
<apex:commandButton value="Reset" action="{!reset}"/>
<apex:commandButton value="Generate Pdf" action="{!Showpdf}"/>
</apex:PageBLockButtons>
<apex:OutputLabel value="{!message}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
--
controller
 ublic class VendorRegClass {
public string VendorCompanyName{get;set;}
public string VendorContactPerson{get;set;}
public string AmountPerEvent{get;set;}
public string City{get;set;}
public string country{get;set;}
public string render{set;get;}
public boolean showpdf{set;get;}
public static void Send(){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'abc@yahoo.com'};
mail.setToAddresses(toAddresses);
mail.setBccSender(false);
mail.setSubject('Subject');
mail.setPlainTextBody('Test Message Body');
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
for ( Messaging.SendEmailResult result : r ) {
if ( !r[0].isSuccess () ) {
System.debug ( result );
}
else {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Email Sent Successfully' ); ApexPages.addMessage(msg);
} } }
public static void reset(){
VendorCompanyName='';
VendorContactPerson='';
AmountPerEvent='';
City=''; country='';
}
public static void ShowPdf(){
if(render==null){ render='pdf';
} }}
I want to create calculator which will show discount base don number of students.
1 studnet & 1 course=  0 discount, 1 student & many courses = 10*coursenumber  & so on.
i have written code but showing error  for 
conditipn expression mustbe booleasn, unexpected token{, 

controller: 
public class calculatorclass {
    
    public integer studentNumber{get;set;}
    public integer CoursesNumber{get;set;}
    public double Discount{get;set;}
    
    public void Discount(){
        
        if (studentNumber= 1 && CoursesNumber= 1  )
        {
            Discount=0;
        }
                 else if (studentNumber= 1 && CoursesNumber > 1  )
        { 
            Discount= 10 * CoursesNumber ;
        }
         else if (studentNumber> 1 && CoursesNumber = 1  )
        { 
            Discount= 15 * studentNumber;
           
        }
         else if (studentNumber> 1 && CoursesNumber > 1  )
        { 
            Discount= (15 * studentNumber)+ (10*CoursesNumber );
                If(Discount >60) 
               Discount= 60;
            else
            { 
                discount =(15 * studentNumber)+ (10*CoursesNumber ) ;
                }
               }
}
}

VFP: 
<apex:page controller= "calculatorclass ">
    <apex:form>
    <apex:pageBlock title= "discount Calculator" >
        <apex:OutputLabel value="Number of student"/>
        <apex:inputText value="{!studentNumber}"/>
        
        <apex:OutputLabel value="Number of Courses"/>
        <apex:inputText value="{!CoursesNumber}"/>
        <apex:CommandButton value="calculate discount" action="{!Discount}"/>
        <apex:OutputLabel id="id1"> {!Discount} </apex:OutputLabel>
        
        </apex:pageBlock>
    
    </apex:form>
</apex:page>
I want to send email to trainer dept and bcc to CEO, and want to share the data of training object in object 
 
i m trying to show trainer deals  object data & trainer master object data on sameVFP. , it is showing only training deals(details obj) data  but not trainer master data.(master objt)
controller:
public class trainingDealclass {
  public list<Trainer_master__c> traininglist{get;set;}     public trainingdealclass(){
        traininglist= [SELECT First_name__c, Last_name__c, Education__c,SELECT Course_c  FROM CRN_Training_deals__r)
                      FROM Trainer_master__c LIMIT 10];
    }
}
----
VFP
<apex:page controller="TrainingDealClass">
    <apex:form>
    <apex:Pageblock title="training details">
        <apex:pageblocktable value="{!traininglist}" var="a">
            <apex:column value="{!a.First_name__c}"/>
            <apex:column value="{!a.Last_name__c}"/>
            <apex:column value="{!a.Education__c}"/>
           
         <apex:pageBlockTable value="{!a.CRN_Training_deals__r}" var="b">  
            <apex:column value="{!b.Course__c}"/>
             </apex:pageBlockTable>
            
        </apex:pageblocktable>
        </apex:Pageblock>
    </apex:form>
</apex:page>

 
Whenever u are updating account object , find the number of contact which are present on account itself.show that count on account object
why cant we write validation rule on deleting record
Write a trigger whenever account created, no contact is associated to that account, create dummy contact with contact name as account name. need to check no contact is associated with it and then create dummy contact
which lightning interfce is used to make component avaible for all features
i want to create field for expiry month for card & another field for expiry year of card , which data type shall i use 
in VFP inputtext is empty , then i want to disable the send button .
if inputfield is entered then only user can able to click teh send button
I want to create calculator which will show discount base don number of students.
1 studnet & 1 course=  0 discount, 1 student & many courses = 10*coursenumber  & so on.
i have written code but showing error  for 
conditipn expression mustbe booleasn, unexpected token{, 

controller: 
public class calculatorclass {
    
    public integer studentNumber{get;set;}
    public integer CoursesNumber{get;set;}
    public double Discount{get;set;}
    
    public void Discount(){
        
        if (studentNumber= 1 && CoursesNumber= 1  )
        {
            Discount=0;
        }
                 else if (studentNumber= 1 && CoursesNumber > 1  )
        { 
            Discount= 10 * CoursesNumber ;
        }
         else if (studentNumber> 1 && CoursesNumber = 1  )
        { 
            Discount= 15 * studentNumber;
           
        }
         else if (studentNumber> 1 && CoursesNumber > 1  )
        { 
            Discount= (15 * studentNumber)+ (10*CoursesNumber );
                If(Discount >60) 
               Discount= 60;
            else
            { 
                discount =(15 * studentNumber)+ (10*CoursesNumber ) ;
                }
               }
}
}

VFP: 
<apex:page controller= "calculatorclass ">
    <apex:form>
    <apex:pageBlock title= "discount Calculator" >
        <apex:OutputLabel value="Number of student"/>
        <apex:inputText value="{!studentNumber}"/>
        
        <apex:OutputLabel value="Number of Courses"/>
        <apex:inputText value="{!CoursesNumber}"/>
        <apex:CommandButton value="calculate discount" action="{!Discount}"/>
        <apex:OutputLabel id="id1"> {!Discount} </apex:OutputLabel>
        
        </apex:pageBlock>
    
    </apex:form>
</apex:page>
I want to send email to trainer dept and bcc to CEO, and want to share the data of training object in object 
 
i m trying to show trainer deals  object data & trainer master object data on sameVFP. , it is showing only training deals(details obj) data  but not trainer master data.(master objt)
controller:
public class trainingDealclass {
  public list<Trainer_master__c> traininglist{get;set;}     public trainingdealclass(){
        traininglist= [SELECT First_name__c, Last_name__c, Education__c,SELECT Course_c  FROM CRN_Training_deals__r)
                      FROM Trainer_master__c LIMIT 10];
    }
}
----
VFP
<apex:page controller="TrainingDealClass">
    <apex:form>
    <apex:Pageblock title="training details">
        <apex:pageblocktable value="{!traininglist}" var="a">
            <apex:column value="{!a.First_name__c}"/>
            <apex:column value="{!a.Last_name__c}"/>
            <apex:column value="{!a.Education__c}"/>
           
         <apex:pageBlockTable value="{!a.CRN_Training_deals__r}" var="b">  
            <apex:column value="{!b.Course__c}"/>
             </apex:pageBlockTable>
            
        </apex:pageblocktable>
        </apex:Pageblock>
    </apex:form>
</apex:page>

 
I have a custom object course__c. Requirement: When I enter the course name and press button, it should search the related deals from object Training_Deal__c.Course and Training_Deal are connected by MDR. If there are records matching the course name, it should show the deal details, else throw error:no records found. But whenever I enter non matching course name, it is not throwing error and showing the same deal details for all the courses in the database.
Appreciate any help to fix this.

Controller:
public class Dealsclass { public string Courses{set;get;}
public static list<Training_Deal__c> results{get;set;}
//public static list<Course_Master__c> cours{get;set;}
public Dealsclass(){ results=null; //cours=null; }
public static void searchdeals(){
//List<Course_Master__c> cours=[SELECT Course_Name__c From Course_Master__c];
results=[SELECT Discount_Percentage__c,Discount_Reason__c,Fees_Paid_by_Student__c,Deal_Risk_Status__c,Course__r.Name FROM Training_Deal__c WHERE Course__r.Name IN ('Java')]; if(results.size()==0){
ApexPages.Message msg1= new ApexPages.Message(ApexPages.Severity.ERROR,'No results Found');
ApexPages.addMessage(msg1); } } }
Visualforce page :
<apex:page controller="Dealsclass" >
<apex:form >
<apex:pageBlock >
<apex:outputPanel >
<apex:pageMessages ></apex:pageMessages> </apex:outputPanel>
<apex:outputLabel >
Course to search</apex:outputLabel>
<apex:inputText value="{!Courses}"/>
<apex:commandButton value="search" action="{!searchdeals}"/> <apex:pageBlockTable value="{!results}" var="d">
<apex:column value="{!d.Discount_Percentage__c}"/> <apex:column value="{!d.Discount_Reason__c}"/>
<apex:column value="{!d.Fees_Paid_by_Student__c}"/> <apex:column value="{!d.Deal_Risk_Status__c}"/>
<apex:column value="{!d.Course__r.Name}"/> </apex:pageBlockTable>

</apex:pageBlock>
</apex:form>
</apex:page>
I want to insert all the input field values of a template into custom fields of an object in LWC. Could anyone please give me a solution. Below is the code which I have written so far. But I come up with this error(insert failed. First exception on row 0; first error: INVALID_TYPE_ON_FIELD_IN_RECORD, First_Name: value not of required type: {fieldApiName=First_Name__c, objectApiName=Registration__c}: [First_Name__c])
 
    HTML:
    <lightning-input type="text" name="txtFname" label="Enter First Name" onchange={handleChange} value={regRecord.fName}></lightning-input>
      <lightning-button variant="success" label="Submit" title="Submit" onclick={saveRecord} class="slds-m-left_x-small"></lightning-button>
    
    Javascript:
    
    import FirstName_FIELD from '@salesforce/schema/Registration__c.First_Name__c';
    import saveRegRecord from '@salesforce/apex/regClass.createRecord';
    
    @track regRecord = {
            fName : FirstName_FIELD
        };
    
        handleChange(event) {
            const field = event.target.name;
            if (field === 'txtFname') {
                console.log(event.target.value);
                this.regRecord.fName = event.target.value;            
            } 
        }
    
        saveRecord(event)
        {   
            saveRegRecord({reg : this.regRecord})
            .then(result => {
                // Clear the user enter values
                console.log(this.regRecord)
                this.conrec = {};            
                window.console.log('result ===> '+result);
                alert('record inserted');
            })
            .catch(error => {
                this.error = error.message;
                console.log('error==>'+this.error);
                alert('record not inserted');
            });
        }

    Apex:
    @AuraEnabled
        public static void createRecord (Registration__c reg){  
                if(reg != null){
                    insert reg;
            } 
        }