• Nobu.S
  • NEWBIE
  • 30 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
Before (at least in May), I could view properties returned from Apex Class in LWC component properly. However, this week, I found that I can't view properties of those with the same code. (no change both in LWC and ApexClass).
Does someone have any idea what is the cause and how to waive this issue.
Here attached the fraiming of the code and the result of debug log.
 
******apex class*********

@AuraEnabled
public static List<sample> returnSamples(Id oppId){
 List<sample> samles = new List<sample>();
 ...........

 system.debug(samples);  'I could view proper result
 return samples;

}


public class sample{
 @AuraEnabled
 OpportunityLineItem line01{get;set;}
 @AuraEnabled
 OpportunityLineItem line02{get;set;}
 @AuraEnabled
 OpportunityLineItem line03{get;set;}

}

****LWC.js****

import getSamples from '@salesforce/apex/***.returnSamles'

....

getSamples(oppId: this.recordId)
	.then(result =>{			
		if(result){
			console.log('result-->' + JSON.stringfy(result));
'log: result-->[{},{},{},{}]
			console.log('size-->' + result.length);
'log: size-->4
			.....
		}
	});

 
Hello, 

I've created sample LWC to modify sObject list from UI. But when I invoke onchange event which update field value in some sObject, pop-up shows "[NoErrorObjectAvailable] Script error.".


Here is my sample code and error happens on the js line
//this.wiredAccount[idx][fname] = evt.target.value;//

Previous console.log shows properly the target field value. So I have no idea what cause the error. Could somebody teach me what is the cuase?
import { LightningElement, track, wire} from 'lwc';

import getList from '@salesforce/apex/manageAccListCtrl.getAccList';

export default class manageAccList extends LightningElement {
    @track wiredAccounts;
    @wire(getList)
        fetchAccs(result){
            this.wiredAccounts = result.data;
        } 

    chgValHandler(evt){
        var idx = evt.target.dataset.index * 1;
        var fname = evt.target.dataset.field;
        console.log("idx,fname,val:" + idx + "," + fname + "," + evt.target.value);
        console.log("wiredtarget:" + this.wiredAccounts[idx][fname]);        
        this.wiredAccounts[idx][fname] = evt.target.value;
        console.log(JSON.stringify(this.wiredAccounts));
    }

}
<lightning-card icon-name="custom:custom14" title="manage account">        
     
        <div class="slds-table--header-fixed_container">
        <div class="slds-scrollable_y" style="height: 100%;" >

        <table class="slds-table slds-table--header-fixed">
            <thead>
                <tr class="slds-text-title_caps">
                    <th scope="col"><div class="slds-truncate slds-cell-fixed">Id</div></th>
                    <th scope="col"><div class="slds-truncate slds-cell-fixed">Account Name</div></th>
                    <th scope="col"><div class="slds-truncate slds-cell-fixed">Account Number</div></th>
                </tr>
            </thead>

            <template if:true={wiredAccounts} >
                <tbody>                                            
                    <template for:each={wiredAccounts} for:item="acc" for:index="idx">
                        <tr key={acc.Id} class="slds-hint-parent">
                            <th>
                                {acc.Id}
                            </th>
                            <td>
                                <lightning-input value={acc.Name} data-index={idx} data-field="Name" onchange={chgValHandler} ></lightning-input>
                            </td>
                            <td>
                                <lightning-input value={acc.AccountNumber} data-index={idx} data-field="AccountNumber" onchange={chgValHandler}></lightning-input>
                            </td>
                        </tr>
                    </template>
                </tbody>
            </template>
        
        </table>
        </div>  
        </div>
    </lightning-card>
</template>
商談の詳細画面に配置したカスタムボタンからApexのWebServiceを呼び出していますが、処理に非常に時間がかかるため、その間ローディング画面等にしておきたいと考えます。
BlockUIのプラグインを使うことを想定しています。

意図しているところは、ブロック->Webservice呼び出し->ブロック解除ですが、実際の挙動がWebService処理->ブロック->ブロック解除となってしまいます。(解除部分をSetTimeoutで確認)
Promiseを使用しても結果が変わりません。
意図する順番通りの処理となるような方法はありませんでしょうか?(BlockUIのツールにはこだわりません)
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
{!REQUIRESCRIPT('/resource/' &  LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jQuery')} // includescript jQuery
{!REQUIRESCRIPT('/resource/' &  LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jQueryBlockUI')} //includescript jQueryBlockUI

var $ = jQuery.noConflict(); 
var promise = Promise.resolve(); 

function block(){$.blockUI();}
function unblock(){$.unblockUI();}
function exeWS(){
var retStr; 
retStr = sforce.apex.execute("ApexClass", "WebserviceMethod", {oppId:'{!Opportunity.Id}'});
alert(retStr);
}

promise.then(block).then(exeWS).then(unblock);
window.location.reload();
  • January 30, 2018
  • Like
  • 1
Hello.

I created an Apex Class for csv data importing function. When a data for CurrencyIsoCode was wrong/blank, 'try/catch' like code below doesn't work and salesforce shows a validation error.
*my organization uses multi-currency function
String cur = 'USDD';
PriceBookEntry pbe = new PriceBookEntry();
try{
pbe.CurrencyIsoCode = cur;
} catch(Exxception e){
....
}

To avoid this situation, I'd like to get current CurrencyIsoCode list in the apex class. Is there some way to get such list as Set<String>?
Visualforce Pageのjavascriptでコントローラの変数の値を取得しようとした場合に、意図した値が取れません。

具体的には、以下のコードにてコマンドボタンを押してメソッドを実行した際に、Apex:outputTextには意図したresultMessage ("Hello" + userName)の値が出力されますが、scriptでのアラートメッセージとしてのresultMessageには何も表示されません(null値のまま)。

この違いは何に起因するものでしょうか?ご教示いただければ幸いです。
<apex:page controller="HelloCtrl">
    <script>
    function showMessage(){
        alert("{!resultMessage}");
    }
    </script>
    <h1>Greeting!</h1>
    <apex:form id="frm">
        Your Name
        <apex:inputText label="name" value="{!userName}"/>
        <apex:commandButton value="showMsg" action="{!createMessage}" oncomplete="showMessage()" reRender="frm" />
        <apex:outputtext value="{!resultMessage}" />
    </apex:form>
</apex:page>
public class HelloCtrl {
    public String initialMessage;
    public String userName{get;set;}
    public String resultMessage{get;set;}
    
    public HelloCtrl(){
        initialMessage = 'Hello ';
    }   
    
    public Pagereference createMessage(){
        if(userName != null){
            resultMessage = initialMessage + userName;
        }else{
            resultMessage = initialMessage;
        } 
        return null;
    }
    
}

 
  • October 26, 2016
  • Like
  • 0
商談の詳細画面に配置したカスタムボタンからApexのWebServiceを呼び出していますが、処理に非常に時間がかかるため、その間ローディング画面等にしておきたいと考えます。
BlockUIのプラグインを使うことを想定しています。

意図しているところは、ブロック->Webservice呼び出し->ブロック解除ですが、実際の挙動がWebService処理->ブロック->ブロック解除となってしまいます。(解除部分をSetTimeoutで確認)
Promiseを使用しても結果が変わりません。
意図する順番通りの処理となるような方法はありませんでしょうか?(BlockUIのツールにはこだわりません)
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
{!REQUIRESCRIPT('/resource/' &  LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jQuery')} // includescript jQuery
{!REQUIRESCRIPT('/resource/' &  LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jQueryBlockUI')} //includescript jQueryBlockUI

var $ = jQuery.noConflict(); 
var promise = Promise.resolve(); 

function block(){$.blockUI();}
function unblock(){$.unblockUI();}
function exeWS(){
var retStr; 
retStr = sforce.apex.execute("ApexClass", "WebserviceMethod", {oppId:'{!Opportunity.Id}'});
alert(retStr);
}

promise.then(block).then(exeWS).then(unblock);
window.location.reload();
  • January 30, 2018
  • Like
  • 1
Before (at least in May), I could view properties returned from Apex Class in LWC component properly. However, this week, I found that I can't view properties of those with the same code. (no change both in LWC and ApexClass).
Does someone have any idea what is the cause and how to waive this issue.
Here attached the fraiming of the code and the result of debug log.
 
******apex class*********

@AuraEnabled
public static List<sample> returnSamples(Id oppId){
 List<sample> samles = new List<sample>();
 ...........

 system.debug(samples);  'I could view proper result
 return samples;

}


public class sample{
 @AuraEnabled
 OpportunityLineItem line01{get;set;}
 @AuraEnabled
 OpportunityLineItem line02{get;set;}
 @AuraEnabled
 OpportunityLineItem line03{get;set;}

}

****LWC.js****

import getSamples from '@salesforce/apex/***.returnSamles'

....

getSamples(oppId: this.recordId)
	.then(result =>{			
		if(result){
			console.log('result-->' + JSON.stringfy(result));
'log: result-->[{},{},{},{}]
			console.log('size-->' + result.length);
'log: size-->4
			.....
		}
	});

 
商談の詳細画面に配置したカスタムボタンからApexのWebServiceを呼び出していますが、処理に非常に時間がかかるため、その間ローディング画面等にしておきたいと考えます。
BlockUIのプラグインを使うことを想定しています。

意図しているところは、ブロック->Webservice呼び出し->ブロック解除ですが、実際の挙動がWebService処理->ブロック->ブロック解除となってしまいます。(解除部分をSetTimeoutで確認)
Promiseを使用しても結果が変わりません。
意図する順番通りの処理となるような方法はありませんでしょうか?(BlockUIのツールにはこだわりません)
 
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
{!REQUIRESCRIPT('/resource/' &  LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jQuery')} // includescript jQuery
{!REQUIRESCRIPT('/resource/' &  LEFT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(TEXT(NOW()),':',''),'-',''),' ',''),10) & '000/jQueryBlockUI')} //includescript jQueryBlockUI

var $ = jQuery.noConflict(); 
var promise = Promise.resolve(); 

function block(){$.blockUI();}
function unblock(){$.unblockUI();}
function exeWS(){
var retStr; 
retStr = sforce.apex.execute("ApexClass", "WebserviceMethod", {oppId:'{!Opportunity.Id}'});
alert(retStr);
}

promise.then(block).then(exeWS).then(unblock);
window.location.reload();
  • January 30, 2018
  • Like
  • 1
Hello.

I created an Apex Class for csv data importing function. When a data for CurrencyIsoCode was wrong/blank, 'try/catch' like code below doesn't work and salesforce shows a validation error.
*my organization uses multi-currency function
String cur = 'USDD';
PriceBookEntry pbe = new PriceBookEntry();
try{
pbe.CurrencyIsoCode = cur;
} catch(Exxception e){
....
}

To avoid this situation, I'd like to get current CurrencyIsoCode list in the apex class. Is there some way to get such list as Set<String>?
Visualforce Pageのjavascriptでコントローラの変数の値を取得しようとした場合に、意図した値が取れません。

具体的には、以下のコードにてコマンドボタンを押してメソッドを実行した際に、Apex:outputTextには意図したresultMessage ("Hello" + userName)の値が出力されますが、scriptでのアラートメッセージとしてのresultMessageには何も表示されません(null値のまま)。

この違いは何に起因するものでしょうか?ご教示いただければ幸いです。
<apex:page controller="HelloCtrl">
    <script>
    function showMessage(){
        alert("{!resultMessage}");
    }
    </script>
    <h1>Greeting!</h1>
    <apex:form id="frm">
        Your Name
        <apex:inputText label="name" value="{!userName}"/>
        <apex:commandButton value="showMsg" action="{!createMessage}" oncomplete="showMessage()" reRender="frm" />
        <apex:outputtext value="{!resultMessage}" />
    </apex:form>
</apex:page>
public class HelloCtrl {
    public String initialMessage;
    public String userName{get;set;}
    public String resultMessage{get;set;}
    
    public HelloCtrl(){
        initialMessage = 'Hello ';
    }   
    
    public Pagereference createMessage(){
        if(userName != null){
            resultMessage = initialMessage + userName;
        }else{
            resultMessage = initialMessage;
        } 
        return null;
    }
    
}

 
  • October 26, 2016
  • Like
  • 0