• Abers55
  • NEWBIE
  • 35 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Hi,

I wrote a piece of code to update the chatter photo for a user using the chatter API.  It's been working successfully,  however,  now it has stopped working.

The code looks like this:
Document content = [select Body from Document where id ='***known id***'];

ConnectApi.Photo photo = ConnectApi.ChatterUsers.setPhoto(null, UserInfo.getUserId(),  new ConnectApi.BinaryInput(content.Body,'image/jpg','userImage.jpg'));
I don't think that there's anything wrong with the code.  I have noticed that I cannot even update the picture from my chatter page anymore.  So,  is there some sort of limit that I have broken?
I have written a simple component that outputs data based on an account selected on screen by the user.  When the user selects the account,  the Id is picked up from the change event and the data is generated using a a wired property.  However,  the data does not update onscreen.  
  • I can't tell if the propery is being populated or not
  • I can see that the getter does not fire to populate the data,  but,  I don't know why
Here's my code:
<template>
    <lightning-card
        title="Account Address"
        icon-name="standard:account"
    >
        <div class="slds-m-around_medium">

            <lightning-record-edit-form object-api-name="Contact" record-id={recordId}>
                <lightning-messages></lightning-messages>
                <lightning-input-field field-name="AccountId" onchange={handleAccountChange}></lightning-input-field>
            </lightning-record-edit-form>

            <lightning-input type="text" label="Billing Street" value={billingStreet}></lightning-input>
            <lightning-input type="text" label="Billing City" value={billingCity}></lightning-input>
            <lightning-input type="text" label="Billing Postal Code" value={billingPostalCode}></lightning-input>
            <lightning-input type="text" label="Billing Country" value={billingCountry}></lightning-input>
           
        </div>
        
    </lightning-card>
    
</template>
 
import { LightningElement, api, wire} from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';

import Account_BillingStreet_Field from '@salesforce/schema/Account.BillingStreet';
import Account_BillingCity_Field from '@salesforce/schema/Account.BillingCity';
import Account_BillingPostalCode_Field from '@salesforce/schema/Account.BillingPostalCode';
import Account_BillingCountry_Field from '@salesforce/schema/Account.BillingCountry';

const ACCOUNT_ADDRESS_FIELDS = [Account_BillingStreet_Field, Account_BillingCity_Field, Account_BillingPostalCode_Field, Account_BillingCountry_Field];

export default class accountAddressDisplay_v2 extends LightningElement {
    recordId;
    accountId;

    @wire (getRecord, { recordId: '$accountId', fields: ACCOUNT_ADDRESS_FIELDS })
    account

    handleAccountChange(event) {
        const newAccountId = event.detail.value;
        console.log('newAccountId: ' + newAccountId);

        if(newAccountId.length > 0) {
            this.accountId = newAccountId;
            console.log('this.accountId: ' + this.accountId);
        }
    }

    get billingStreet() {
        console.log('billingStreet get request made');
        return getFieldValue(this.account.data, Account_BillingStreet_Field);
    }

    get billingCity() {
        return getFieldValue(this.account.data, Account_BillingCity_Field);
    }

    get billingCountry() {
        return getFieldValue(this.account.data, Account_BillingCountry_Field);
    }

    get billingPostalCode() {
        return getFieldValue(this.account.data, Account_BillingPostalCode_Field);
    }

    displayError(error) {
        let message = 'Unknown error';
        if (Array.isArray(error.body)) {
            message = error.body.map(e => e.message).join(', ');
        } else if (typeof error.body.message === 'string') {
            message = error.body.message;
        }
        this.dispatchEvent(
            new ShowToastEvent({
                title: 'Error loading opportunity',
                message,
                variant: 'error',
            }),
        );
    }
}

What am I missing here?
I've written a very simple component to play around with toastEvents,  but,  I'm having trouble getting them to display an icon of my chosing.  The documentation says to set the type parameter to "other" and then use an icon defined in the SLDS.  Here's my code:

Component
<aura:component implements="flexipage:availableForAllPageTypes">
    <lightning:button variant="brand" label="Toast" iconName="utility:event" iconPosition="left" onclick="{! c.handleClick }" />
</aura:component>
Controller
({
    handleClick : function(component, event, helper) {        
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            "title": "The toast pops up",
            "message": "Toast event fired",
            "mode": "sticky",
            "type": "other",
            "key": "utility:event"
        });
        toastEvent.fire();
    }
})
No matter what value I supply in the key parameter,  I can't seem to get a result and there don't seem to be any examples of it's use.  Anyone out there succeeded with this?

 

I'd like to share some data across 2 visualforce pages,  so I developed 2 pages that share a single controller:

PageOne

<apex:page controller="PageOne">
    <apex:form >
        <apex:inputText value="{!ThingOne}"/>
        <apex:commandButton value="Next" action="{!Next}"/>
    </apex:form>
</apex:page>

 and PageTwo 

<apex:page controller="PageOne">
    <apex:form >
        <apex:inputText value="{!ThingOne}"/>
        <apex:commandButton value="Previous" action="{!Previous}"/>
    </apex:form>
</apex:page>

 share

public with sharing class PageOne {

    public PageReference Previous() {
        return new PageReference('/apex/PageOne');
    }

    public PageReference Next() {
        return new PageReference('/apex/PageTwo');
    }

    public String ThingOne { get; set; }
}

 Which works fine and I'm happy.

 

However,  supposing Page One had a great deal of complexity and Page Two had a very simple visual output that was based on a result of this complexity.  I'd like to remove the complexity from the work to be done by Page Two,  so,  it seemed to me that the best way to do this would be to continue to share the custom controller and to use an extension on each page.  The code now reads:

PageOne:

<apex:page controller="PageOne" extensions="PageOneExt">
    <apex:form >
        <apex:inputText value="{!ThingOne}"/>
        <apex:commandButton value="Next" action="{!Next}"/>
    </apex:form>
</apex:page>
public with sharing class PageOneExt {
    public PageOne pageController;

    public PageOneExt(PageOne controller) {
        pageController = controller;
        system.debug('***pageController: ' + pageController);
    }

}

 

PageTwo:

<apex:page controller="PageOne" extensions="PageTwoExt">
    <apex:form >
        <apex:inputText value="{!ThingOne}"/>
        <apex:commandButton value="Previous" action="{!Previous}"/>
    </apex:form>
</apex:page>

 

public with sharing class PageTwoExt {
    public PageOne pageController;
    
    public PageTwoExt(PageOne controller) {
        pageController = controller;
/*
* Do a work here with data from Page One
*/ system.debug('***pageController: ' + pageController); } }

 However,  the ThingOne string is no longer shared between the pages and I don't understand why.  Am I doing something wrong or missing the point somewhere?

 

  • September 06, 2013
  • Like
  • 0
I am getting below code scan issues could you please suggest me to resolve or is there any best way to reduce the complexity.
The method 'createTicket1' has a Cyclomatic Complexity of 57.
The method createTicket1() has an NPath complexity of 832

below method
-----------------
Public static void createTicket1(List<case> caseList) {
        system.debug('csirEarlyId '+csirEarlyId);
        final List<Customer_Support_Internal_Request__c> newCsir = new List<Customer_Support_Internal_Request__c>();
       final Set<Id> accId = new Set<Id>();
        final Set<Id> pid = new set<Id>();
        final List<RecordType> listReTyp = new List<RecordType>([select Id,Name from RecordType where sObjectType='Case' AND Name LIKE 'Complaint Question%']);
        Boolean recFlag = false;
        for(Case cse : caseList) {
            for(RecordType rt : listReTyp) {
              if(cse.RecordTypeId == rt.Id) {
                  recFlag = true;
              }
                
            }
            
        }
        for(Case acCase : caseList) {
            accId.add(acCase.AccountId);
        }
        for(Case pids : caseList) {
            pid.add(pids.Patient__c);
        }
        final List<Case> cListMonth = [Select id,Account.name,AccountId from Case Where AccountId = :accId and CreatedDate = THIS_MONTH];
        final List<Case> cListQuarter = [Select id,Account.name,AccountId from Case Where AccountId = :accId and CreatedDate = THIS_QUARTER limit 100];
        final List<case> cListPid = [select id,Patient__c from Case where Patient__c != null and Patient__c =:pid and CreatedDate = THIS_QUARTER limit 100];
        system.debug('cListPid '+cListPid.size());
                                    system.debug('PIDTEST '+pid);
        for(case cs : caseList) {
            if(pid != null && accId != null && recFlag == true && cs.Category__c =='Product Deficiency' && cs.Complaint_Type__c == 'Aligner/retainer Fit Issues' 
                && cs.Complaint_Sub_Type__c =='Case Related'&&cs.Root_Cause__c =='Fit Issues due to Path of Insertion (whole arch)'
                                &&(cListMonth.size()>=3||cListQuarter.size()>=3||cListPid.size()>=2)) {
                                    system.debug('cListMonth '+cListMonth.size());
                                    system.debug('cListQuarter '+cListQuarter.size());
                                    system.debug('cListPid '+cListPid.size());
                                    system.debug('PIDTEST '+pid);
                   final Customer_Support_Internal_Request__c csir = new Customer_Support_Internal_Request__c();
                   csir.RecordTypeId = csirEarlyId;
                   csir.Ticket__c = cs.Id;
                   csir.Description__c = 'early alert system test';
                   csir.Status__c = 'In Progress';
                   csir.Ticket_Origin__c = 'Phone';
                   csir.Category__c = 'Product Deficiency';
                   csir.Complaint_type__c = 'Aligner/retainer Fit Issues';
                   csir.Complaint_Sub_Type__c = 'Case Related';
                   csir.Root_Cause__c = 'Fit Issues due to Path of Insertion (whole arch)';
                   csir.Trend_identified__c = '4 complaints per account in the same month';
                   csir.Account__c = cs.AccountId;
                   csir.Region__c = cs.Region__c;
                   csir.Patient__c = cs.Patient__c;
                   newCsir.add(csir);     
               } else if(recFlag == true && (cs.Category__c =='Product Deficiency' && cs.Complaint_Type__c == 'Clinical Outcome' 
                && cs.Complaint_Sub_Type__c =='Aligner partially expressed  movements'&&cs.Root_Cause__c =='Movements expressed in half')
                    &&(cListMonth.size()>=3||cListQuarter.size()>=3||cListPid.size()>=2)) {
                        system.debug('cListMonth '+cListMonth);
                                    system.debug('cListQuarter '+cListQuarter);
                                    system.debug('cListPid '+cListPid);
                        final Customer_Support_Internal_Request__c csir = new Customer_Support_Internal_Request__c();
                   csir.RecordTypeId = csirEarlyId;
                   csir.Ticket__c = cs.Id;
                   csir.Description__c = 'early alert system test';
                   csir.Status__c = 'In Progress';
                   csir.Ticket_Origin__c = 'Phone';
                   csir.Category__c = 'Product Deficiency';
                   csir.Complaint_type__c = 'Clinical Outcome';
                   csir.Complaint_Sub_Type__c = 'Aligner partially expressed  movements';
                   csir.Root_Cause__c = 'Movements expressed in half';
                    csir.Trend_identified__c = '3 complaints per account in the same month';
                  csir.Account__c = cs.AccountId;
                   csir.Region__c = cs.Region__c;
                   csir.Patient__c = cs.Patient__c;
                   newCsir.add(csir);
            } else if(recFlag == true && cs.Category__c =='Product Deficiency' && cs.Complaint_Type__c == 'Treatment Complaints' && cs.Complaint_Sub_Type__c =='Design Execution'&&cs.Root_Cause__c =='Patient Records not properly examined'&& (cListMonth.size()>=3||cListQuarter.size()>=3||cListPid.size()>=2)) {
                  final Customer_Support_Internal_Request__c csir = new Customer_Support_Internal_Request__c();
                   csir.RecordTypeId = csirEarlyId;
                   csir.Ticket__c = cs.Id;
                   csir.Description__c = 'early alert system test';
                   csir.Status__c = 'In Progress';
                   csir.Ticket_Origin__c = 'Phone';
                   csir.Category__c = 'Product Deficiency';
                   csir.Complaint_type__c = 'Treatment Complaints';
                   csir.Complaint_Sub_Type__c = 'Design Execution';
                   csir.Root_Cause__c = 'Patient Records not properly examined';
                csir.Trend_identified__c = '3 complaints per account in the same month';
                csir.Account__c = cs.AccountId;
                   csir.Region__c = cs.Region__c;
                   csir.Patient__c = cs.Patient__c;
                   newCsir.add(csir);
            } else if(recFlag == true && cs.Category__c =='Product Deficiency' && cs.Complaint_Type__c == 'Treatment Complaints' && cs.Complaint_Sub_Type__c =='Design Execution'&&cs.Root_Cause__c =='Virtual Gingiva adjustment'&&(cListMonth.size()>=3||cListQuarter.size()>=3||cListPid.size()>=2)) {
                   final Customer_Support_Internal_Request__c csir = new Customer_Support_Internal_Request__c();
                   csir.RecordTypeId = csirEarlyId;
                   csir.Ticket__c = cs.Id;
                   csir.Description__c = 'early alert system test';
                   csir.Status__c = 'In Progress';
                   csir.Ticket_Origin__c = 'Phone';
                   csir.Category__c = 'Product Deficiency';
                   csir.Complaint_type__c = 'Treatment Complaints';
                   csir.Complaint_Sub_Type__c = 'Design Execution';
                   csir.Root_Cause__c = 'Virtual Gingiva adjustment';
                csir.Trend_identified__c = '3 complaints per account in the same month';
                csir.Account__c = cs.AccountId;
                   csir.Region__c = cs.Region__c;
                   csir.Patient__c = cs.Patient__c;
                   newCsir.add(csir);
            }    else if(recFlag == true && cs.Category__c =='Product Deficiency' && cs.Complaint_Type__c == 'Treatment Complaints'&& cs.Complaint_Sub_Type__c =='Design Execution'&&cs.Root_Cause__c =='Features Placement' &&(cListMonth.size()>=3||cListQuarter.size()>=3||cListPid.size()>=2)) {
                   final Customer_Support_Internal_Request__c csir = new Customer_Support_Internal_Request__c();
                   csir.RecordTypeId = csirEarlyId;
                   csir.Ticket__c = cs.Id;
                   csir.Description__c = 'early alert system test';
                   csir.Status__c = 'In Progress';
                   csir.Ticket_Origin__c = 'Phone';
                   csir.Category__c = 'Product Deficiency';
                   csir.Complaint_type__c = 'Treatment Complaints';
                   csir.Complaint_Sub_Type__c = 'Design Execution';
                   csir.Root_Cause__c = 'Features Placement';
                csir.Trend_identified__c = '3 complaints per account in the same month';
                csir.Account__c = cs.AccountId;
                   csir.Region__c = cs.Region__c;
                   csir.Patient__c = cs.Patient__c;
                   newCsir.add(csir);
            }    else if(recFlag == true && cs.Category__c =='Non Valid' && cs.Complaint_Type__c == 'Non Valid' 
                && cs.Complaint_Sub_Type__c =='Anatomy/Geometry/Dentition Changes'&&cs.Root_Cause__c =='Fit Issues due to Relapse'
                    &&(cListMonth.size()>=4||cListQuarter.size()>=5||cListPid.size()>=2)) {
                        final Customer_Support_Internal_Request__c csir = new Customer_Support_Internal_Request__c();
                   csir.RecordTypeId = csirEarlyId;
                   csir.Ticket__c = cs.Id;
                   csir.Description__c = 'early alert system test';
                   csir.Status__c = 'In Progress';
                   csir.Ticket_Origin__c = 'Phone';
                   csir.Category__c = 'Non Valid';
                   csir.Complaint_type__c = 'Non Valid';
                   csir.Complaint_Sub_Type__c = 'Anatomy/Geometry/Dentition Changes';
                   csir.Root_Cause__c = 'Fit Issues due to Relapse';
                csir.Trend_identified__c = '2 complaints per account in the same month';
                csir.Account__c = cs.AccountId;
                   csir.Region__c = cs.Region__c;
                   csir.Patient__c = cs.Patient__c;
                   newCsir.add(csir);
            }
        }
        insert newCsir;
    }

Thanks!!
 
  • March 03, 2023
  • Like
  • 0
Hi All

Please help me in defining the CRON expression for running a scheduler class for every 30th min of an hour 
For example first run should be 9 30 next should be 10 30 next should be 11 30 

 
Custom Tabs 
Help for this Page
You can create new custom tabs to extend Salesforce functionality or to build new application functionality. 

Custom Object Tabs look and behave like the standard tabs provided with Salesforce. Web Tabs allow you to embed external web applications and content within the Salesforce window. Visualforce Tabs allow you to embed Visualforce Pages. Lightning Component tabs allow you to add Lightning Components to the navigation menu in Salesforce1. Lightning Page tabs allow you to add Lightning Pages to the navigation menu in Salesforce1.


I want to create a Custom Lightning component tab .
But the feature is missing though it is described in the help section.User-added image
Hi,

I wrote a piece of code to update the chatter photo for a user using the chatter API.  It's been working successfully,  however,  now it has stopped working.

The code looks like this:
Document content = [select Body from Document where id ='***known id***'];

ConnectApi.Photo photo = ConnectApi.ChatterUsers.setPhoto(null, UserInfo.getUserId(),  new ConnectApi.BinaryInput(content.Body,'image/jpg','userImage.jpg'));
I don't think that there's anything wrong with the code.  I have noticed that I cannot even update the picture from my chatter page anymore.  So,  is there some sort of limit that I have broken?