Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
法人番号をLightningWebComponentで取得する
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yoshi
September 21, 2022
Technology
99
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
法人番号をLightningWebComponentで取得する
Yoshi
September 21, 2022
More Decks by Yoshi
See All by Yoshi
人とAIが共創する ガードレール設計
yoshi17
0
96
AgentforceとSalesforceフローとSlackで実現する 「自走型エージェント」構築手順
yoshi17
0
250
Agentforce_ AIによるカスタマーサポートの変革
yoshi17
0
150
事前設定(ExperienceCloudの設定、テストデータ作成)
yoshi17
0
240
AWTT2026_ハンズオン(Agent Scriptサンプル)
yoshi17
0
26
レポート作成ワークショップ(サンプルデータ作成)
yoshi17
0
52
レポート作成ワークショップ(レポート作成例あり)
yoshi17
0
50
レポート作成ワークショップ(レポート作成例なし)
yoshi17
0
36
【付録】AI関連の重要用語集
yoshi17
0
300
Other Decks in Technology
See All in Technology
Cloudflare Workers 向けアプリを C# で構築する ~WASM Native AOT への道~
nenonaninu
1
1k
Railsのように考える: See through the Master
snoozer05
PRO
5
1.3k
ADKで始める業務改善 - AIエージェント開発時の考えと設計
harappa80
2
260
Genieを崇めよ
kameitomohiro
0
170
事業課題から技術的負債に向き合う
sansantech
PRO
2
2.3k
AI de Idea
kawaguti
PRO
2
130
AIを活用するために決めた "やらないこと" - 価値に注目する / Not betting on AI
soudai
PRO
3
590
アプリログインとWeb認証基盤をつなぐ ASWebAuthenticationSession 作法
shimastripe
1
390
おい、エージェントを使って終わらせろ
nwiizo
3
860
あけおめLINE 傾向とその対策
nasa9084
0
270
SREは、MCPとAutopilotをこう使え!
kazumax55
3
950
現場で役立つ技術負債の効果的な返済方法
masuda220
PRO
11
5k
Featured
See All Featured
Balancing Empowerment & Direction
lara
6
1.3k
It's Worth the Effort
3n
188
29k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Bash Introduction
62gerente
615
220k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
530
Mobile First: as difficult as doing things right
swwweet
225
10k
Optimizing for Happiness
mojombo
378
71k
Done Done
chrislema
186
17k
Ruling the World: When Life Gets Gamed
codingconduct
0
350
Accessibility Awareness
sabderemane
1
220
Heart Work Chapter 1 - Part 1
lfama
PRO
10
36k
Transcript
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 1 / 8 ⽬的 取引先ごとに法⼈番号を管理するため 背景 インボイス制度により企業は「区分記載請求書」に「登録番号」、「適⽤税率」及び「消費税額等」の記載 が追加された書類やデータを交付・保存する必要がある
https://www.nta.go.jp/taxes/shiraberu/zeimokubetsu/shohi/keigenzeiritsu/invoice_about.htm 登録番号の構成は、次のとおりです 法⼈番号を有する課税事業者 「T」(ローマ字) + 法⼈番号(数字13桁) 上記以外の課税事業者(個⼈事業者、⼈格のない社団等) 「T」(ローマ字) + 数字13桁(注) (注)13桁の数字には、マイナンバー(個⼈番号)は⽤いず、法⼈番号とも重複しない事業者ごとの番号 になります。 本記事でやること 経済産業省から提供されている法⼈データ付与ツールを⽤いてSalesforceのLightningWebComponent経由で 取得し、法⼈名と法⼈番号をSalesforceの取引先へ保存する 法⼈番号付与ツール https://info.gbiz.go.jp/tools/nayose/index.html 利⽤申請ページから申請を⾏い、APIキーを取得する https://info.gbiz.go.jp/hojin/user_registration/application
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 2 / 8 実装結果 1.取引先データを表⽰ 2.法⼈番号検索セクションの検索ボタンをクリック 3.該当する法⼈を選択 4.保存ボタンをクリック
5.法⼈名(取引先名)と法⼈番号が書き換わっていることを確認
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 3 / 8 実装内容 LightningWebComponent searchCorporateNumber searchCorporateNumber.html <template>
<lightning-card title="法⼈番号検索"> <div class="slds-var-m-around_medium"> <lightning-button variant="brand" label="検索" title="SearchCorporateNumber" onclick={handleClick} record-id={recordId} class="slds-m- left_x_medium"></lightning-button> </div> </lightning-card> </template> searchCorporateNumber.js import { LightningElement, api, track, wire } from 'lwc'; import searchCorporateNumber from '@salesforce/apex/CorporateInformationController.searchCorporateNumber'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class SearchCorporateNumber extends LightningElement { @api recordId; @track companyInfo; handleClick() { searchCorporateNumber({ accountId: this.recordId }) .then(result => { this.companyInfo = JSON.stringify(result); this.companyInfoMessage = JSON.parse(JSON.stringify(result)) ["message"]; if (this.companyInfoMessage == "200 - OK.") { const e = new CustomEvent('clickbutton', { detail: this.companyInfo}); this.dispatchEvent(e); } else { const evt = new ShowToastEvent({ message: '企業情報の候補がありません', variant: 'info', }); this.dispatchEvent(evt); } }); }
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 4 / 8 }
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 5 / 8 searchCorporateNumber.js-meta.xml <?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle
xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>55.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> </targets> </LightningComponentBundle> corporateNumber corporateNumber.html <template> <c-search-corporate-number onclickbutton={setCompanyInfo} record-id= {recordId}></c-search-corporate-number> <template if:true={companyInfo}> <lightning-card> <lightning-radio-group class="slds-var-m-around_medium" name="radioGroup" label="検索結果" options={options} value={value} onchange={handleChange} type="radio"> </lightning-radio-group> <lightning-button variant="brand" label="保存" title="SaveCorporateNumber" onclick={updateAccountData} class="slds-var-m-around_medium slds- m-left_x_medium"></lightning-button> </lightning-card> </template> <template if:false={companyInfo}> </template> </template>
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 6 / 8 corporateNumber.js import { track,LightningElement,api,wire }
from 'lwc'; import updateAccount from '@salesforce/apex/CorporateInformationController.updateAccount'; import wireSimpleOrComplexData from '@salesforce/apex/CorporateInformationController.wireSimpleOrComplexData'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; export default class CorporateNumber extends LightningElement { @track companyInfo; @track options = []; @track selectedIndex; @api get recordId() { return this.accountId; } set recordId(value) { this.accountId = value; } wiredData; accountId; account; error; @wire(wireSimpleOrComplexData, { accountId: '$_accountId' }) wiredData(result) { this.wiredData = result; if (result.data) { this.account = { ...result.data.accountFromServer }; } else { console.log(result.error); } } setCompanyInfo(event) { this.options = ""; this.companyInfo = JSON.parse(event.detail)["hojin-infos"]; for(var index in this.companyInfo){ const option = { label: this.companyInfo[index].name + '(' + this.companyInfo[index].corporate_number + ') ' + this.companyInfo[index].location, value: index }; this.options = [ ...this.options, option ]; } } handleChange(event) { this.selectedIndex = event.target.value;
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 7 / 8 } updateAccountData() { let newAccount
= {}; newAccount.Id = this.recordId; newAccount.Name = this.companyInfo[this.selectedIndex].name; newAccount.AccountNumber = this.companyInfo[this.selectedIndex].corporate_number; updateAccount({account: newAccount}) .then(() => { const evt = new ShowToastEvent({ message: '保存しました', variant: 'success', }); this.dispatchEvent(evt); this.companyInfo = null; setTimeout(() => { eval("$A.get('e.force:refreshView').fire();"); }, 1000); }) .catch(error => { const evt = new ShowToastEvent({ message: '保存できませんでした', variant: 'error', }); this.dispatchEvent(evt); console.log(error); }); } } corporateNumber.js-meta.xml <?xml version="1.0" encoding="UTF-8"?> <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"> <apiVersion>55.0</apiVersion> <isExposed>true</isExposed> <targets> <target>lightning__AppPage</target> <target>lightning__RecordPage</target> <target>lightning__HomePage</target> </targets> </LightningComponentBundle>
法⼈番号をLightningWebComponentで取得する.md 2022/9/20 8 / 8 Apex CorporateInformationController.cls public with sharing
class CorporateInformationController { @AuraEnabled (cacheable=true) public static Map<String, Object> wireSimpleOrComplexData(String accountId) { Map<String, Object> result = new Map<String, Object>(); Account acc = [SELECT Id, Name, AccountNumber FROM Account WHERE Id =: accountId LIMIT 1]; result.put('accountFromServer', acc); return result; } @AuraEnabled public static Map<String, Object> searchCorporateNumber(String accountId){ try { String accountname = [SELECT Name FROM Account WHERE Id =: accountId].Name; HttpRequest req = new HttpRequest(); String searchKey = EncodingUtil.urlEncode(accountName, 'UTF-8'); req.setEndpoint('https://info.gbiz.go.jp/hojin/v1/hojin?name=' + searchKey + '&page=1&limit=50'); req.setMethod('GET'); req.setHeader('Accept','application/json'); req.setHeader('X-hojinInfo-api-token','利⽤申請して取得したAPIキー'); Http http = new Http(); HTTPResponse res = http.send(req); Map<String, Object> mapJson = (Map<String, Object>)JSON.deserializeUntyped(res.getBody()); return mapJson; } catch (Exception e) { throw new AuraHandledException(e.getMessage()); } } @AuraEnabled public static Account updateAccount(Account account) { update account; return account; } }