Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
(Pratinjau) Perintah untuk bekerja dengan Power Fx
Gunakan perintah ini untuk berinteraksi dengan data di Dataverse menggunakan baris perintah atau skrip. Kurangi waktu dan kompleksitas operasi Dataverse Anda dengan menggunakan Power Fx.
Anda bisa menggunakan rumus yang tercantum dalam referensi Rumus - CLI Power Platform.
Commands
| Command | Description |
|---|---|
| pac power-fx repl | (Pratinjau) Luncurkan PerulanganEval-Print Power Fx interaktif |
| pac power-fx run | (Pratinjau) Menjalankan file instruksi Power Fx |
pac power-fx repl
(Pratinjau) Luncurkan PerulanganEval-Print Power Fx interaktif
Nota
Jika Anda menginstal Power Platform CLI menggunakan Windows MSI, ada masalah yang diketahui di pac power-fx repl mana shell mungkin berhenti merespons saat menggunakan perintah ini.
Parameter Opsional untuk power-fx repl
--environment
-env
Menentukan target Dataverse. Nilainya mungkin berupa URL Guid atau https absolut. Ketika tidak ditentukan, organisasi aktif yang dipilih untuk profil autentikasi saat ini akan digunakan.
Komentar
Perintah ini menyediakan shell untuk menggunakan rumus yang tercantum dalam referensi Rumus - Power Platform CLI.
Mulai repl Power Fx dengan menjalankan perintah berikut:
pac power-fx repl
Setelah itu, Anda dapat menjalankan perintah Power Fx.
Examples
Contoh berikut menunjukkan penggunaan pac power-fx repl perintah.
Menambahkan baris
Collect(Contacts, { firstname: "Patti", lastname: "Fernandez" })
Repl Power Fx merespons dengan yang berikut ini:
{contactid:GUID("118d7b47-8f80-ee11-8179-0022482a40c7"), fullname:"Patti Fernandez", ...}
Bantuan
Jalankan perintah berikut untuk mendapatkan bantuan tentang semua perintah yang tersedia di repl Power Fx:
Help()
Repl Power Fx merespons dengan output berikut:
Abs Acos Acot AddColumns And
Asin AsType Atan Atan2 Average
Blank Boolean Char Clear ClearCollect
Coalesce Collect ColorFade ColorValue Concat
Concatenate Cos Cot Count CountA
CountIf CountRows Date DateAdd DateDiff
DateTime DateTimeValue DateValue Day Dec2Hex
Decimal Degrees Distinct DropColumns EDate
EncodeUrl EndsWith EOMonth Error Exp
Filter Find First FirstN Float
ForAll GUID Help Hex2Dec Hour
If IfError Index Int IsBlank
IsBlankOrError IsEmpty IsError IsMatch IsNumeric
IsToday Language Last LastN Left
Len Ln Log LookUp Lower
Match MatchAll Max Mid Min
Minute Mod Month Not Notify
Now OptionSetInfo Or ParseJSON Patch
Pi PlainText Power Proper Radians
Rand RandBetween Refresh Remove Replace
RGBA Right Round RoundDown RoundUp
Second Sequence Set Shuffle Sin
Sort Split Sqrt StartsWith StdevP
Substitute Sum Switch Table Tan
Text Time TimeValue TimeZoneOffset Today
Trim TrimEnds Trunc Upper Value
VarP Weekday With Year
>>
Nota
Perintah ini akan berubah dari waktu ke waktu untuk menyertakan lebih banyak perintah. Ini harus disinkronkan dengan perintah yang saat ini tersedia yang didokumen.
Exit
Gunakan Exit() untuk keluar dari repl perintah.
pac power-fx run
(Pratinjau) Menjalankan file instruksi Power Fx
Examples
Contoh berikut menunjukkan penggunaan pac power-fx run perintah.
Nota
Dalam setiap contoh ini, Anda perlu:
Buat file bernama
test-pfx.txtdengan ekspresi Power Fx di folder di komputer Anda, sepertic:\test.Buka jendela Windows PowerShell, navigasikan
testke folder dan gunakanrunperintah yang menentukan file yang berisi perintah:pac power-fx run --file test-pfx.txt.
Untuk menggunakan tabel Dataverse, Anda harus membuat dan memilih profil autentikasi. Lihat pac buat autentikasi dan pac pilih autentikasi.
Jika Anda mendapatkan pemeriksaan kesalahan Pemecahan Masalah.
Membuat rekaman Dataverse
Tambahkan teks berikut ke
test-pfx.txtdan simpan file.Collect(Contacts, { firstname: "Megan", lastname: "Bowen" }) Collect(Contacts, { firstname: "Garth", lastname: "Forth" }) Collect(Contacts, { firstname: "Adele", lastname: "Vance" }) Collect(Contacts, { firstname: "Patti", lastname: "Fernandez" })Jalankan perintah ini:
PS C:\test> pac power-fx run --file test-pfx.txtAnda dapat mengharapkan output seperti berikut:
{contactid:GUID("80eb0c02-9180-ee11-8179-0022482a40c7"), fullname:"Megan Bowen", ...} {contactid:GUID("81eb0c02-9180-ee11-8179-0022482a40c7"), fullname:"Garth Forth", ...} {contactid:GUID("82eb0c02-9180-ee11-8179-0022482a40c7"), fullname:"Adele Vance", ...} {contactid:GUID("83eb0c02-9180-ee11-8179-0022482a40c7"), fullname:"Patti Fernandez", ...}
Mengkueri tabel Dataverse
Tambahkan teks ini ke
test-pfx.txtdan simpan file.FirstN(Contacts, 5)Perintah ini mengambil lima kontak pertama dari Dataverse.
Jalankan perintah ini:
PS C:\test> pac power-fx run --file test-pfx.txtAnda dapat mengharapkan output seperti berikut:
Connected to... Your Organization Connected as you@yourorg.onmicrosoft.com contactid fullname ... ============================================== ================== ===== GUID("eeb27495-d127-ed11-9db1-00224804f8e2") Yvonne McKay (sample) GUID("cba0ed9e-d127-ed11-9db1-00224804f8e2") Susanna Stubberod (sample) GUID("cea0ed9e-d127-ed11-9db1-00224804f8e2") Nancy Anderson (sample) GUID("6cc7483c-7a77-ee11-8179-00224809f375") Maria Campbell (sample) GUID("49b0be2e-d01c-ed11-b83e-000d3a572421") Sidney Higa (sample) PS C:\test>
Menggunakan fungsi PowerFx
Tambahkan teks berikut ke
test-pfx.txtdan simpan file.Set(x, 1) Result = If( Mid( "asdf",x,1 ) = "a", "X", "Y" )Jalankan perintah berikut:
PS C:\test> pac power-fx run --file test-pfx.txtAnda dapat mengharapkan output seperti berikut:
PS C:\test> pac power-fx run --file test-pfx.txt x: 1 true Result: "X" PS C:\test>--echoTambahkan parameter dan Anda dapat mengharapkan output ini:PS C:\test> pac power-fx run --file test-pfx.txt --echo Set(x, 1) x: 1 true Result = If( Mid( "asdf",x,1 ) = "a", "X", "Y" ) Result: "X" PS C:\test>
Parameter yang Diperlukan untuk power-fx run
--file
-f
Jalur file yang akan dijalankan
Parameter Opsional untuk power-fx run
--echo
-e
True jika perintah input harus menggema kembali ke output
Parameter ini tidak memerlukan nilai. Ini saklar.
--environment
-env
Menentukan target Dataverse. Nilainya mungkin berupa URL Guid atau https absolut. Ketika tidak ditentukan, organisasi aktif yang dipilih untuk profil autentikasi saat ini akan digunakan.
Troubleshooting
Berikut ini adalah langkah-langkah untuk memecahkan masalah kesalahan yang mungkin Anda temui saat menggunakan pac power-fx perintah.
Kesalahan saat tidak ada profil autentikasi Dataverse
Anda bisa mendapatkan kesalahan seperti ini ketika Anda tidak memiliki profil autentikasi universal yang terkait dengan lingkungan Dataverse.
PS C:\test> pac power-fx run --file test-pfx.txt
Error 8-16: Name isn't valid. 'Contacts' isn't recognized.
Error 18-59: The specified column 'firstname' does not exist.
Error 0-60: The function 'Collect' has some invalid arguments.
Error 8-16: Name isn't valid. 'Contacts' isn't recognized.
Error 18-59: The specified column 'firstname' does not exist.
Error 0-60: The function 'Collect' has some invalid arguments.
Error 8-16: Name isn't valid. 'Contacts' isn't recognized.
Error 18-59: The specified column 'firstname' does not exist.
Error 0-60: The function 'Collect' has some invalid arguments.
Error 8-16: Name isn't valid. 'Contacts' isn't recognized.
Error 18-63: The specified column 'firstname' does not exist.
Error 0-64: The function 'Collect' has some invalid arguments.
Untuk mengatasi kesalahan seperti ini, buat profil autentikasi universal yang terkait dengan lingkungan Dataverse.
Jalankan daftar autentikasi perintahpac.
Anda mungkin melihat hasil seperti berikut ini yang menyertakan profil autentikasi
UNIVERSALtanpa Url yang menunjukkan bahwa profil tersebut terkait dengan lingkungan Dataverse.Index Active Kind Name Friendly Name Url User Cloud Type [1] * UNIVERSAL you@yourcompany.com Public OperatingSystemIni tidak cukup karena tidak ada lingkungan Dataverse yang ditentukan.
Gunakan pac buat autentikasi untuk membuat profil autentikasi yang
UNIVERSALtersambung ke lingkungan Dataverse.Nota
--environmentGunakan parameter menggunakan nilai environmentid. Temukan ID lingkungan Anda.Jangan gunakan
--urlparameter karena ini akan membuatDATAVERSEprofil daripadaUNIVERSALprofil.Contohnya:
PS C:\test> pac auth create --environment f2cef599-b112-4803-bb5d-090077017685 --name ConnectionName 'you@yourcompany.onmicrosoft.com' authenticated successfully. Validating connection... Default organization: YourOrganization Connected to... YourOrganization Connected as you@yourcompany.onmicrosoft.com Authentication profile created * UNIVERSAL ConnectionName https://yourcompany.crm.dynamics.com/ : you@yourcompany.onmicrosoft.com Public PS C:\test>Jalankan pac daftar autentikasi lagi. Anda akan melihat hasil dengan
UNIVERSALprofil koneksi dengan URL untuk lingkungan Dataverse Anda.PS C:\test> pac auth list Index Active Kind Name Friendly Name Url User Cloud Type [1] * UNIVERSAL you@yourcompany.com Public OperatingSystem [2] * UNIVERSAL ConnectionName YourOrganization https://yourcompany.crm.dynamics.com/ you@yourcompany.com Public User PS C:\test>UNIVERSALPilih lingkungan untuk menjadikannya profil default menggunakan pac perintah pilih autentikasi.PS C:\test> pac auth select --index 2 New default profile: * UNIVERSAL ConnectionName https://yourcompany.crm.dynamics.com/ : you@yourcompany.com Public PS C:\test>
Lihat juga
Grup Perintah CLI Microsoft Power Platform
Gambaran umum CLI Microsoft Power Platform