שתף דרך


pac power-fx

(תצוגה מקדימה) פקודות לעבודה עם Power Fx

השתמש בפקודות אלה כדי ליצור אינטראקציה עם נתונים ב- Dataverse באמצעות שורת פקודה או סקריפט. הפחת את הזמן ואת המורכבות של פעולות Dataverse באמצעות Power Fx.

באפשרותך להשתמש בנוסחאות המפורטות בהפניה לנוסחה - Power Platform CLI.

פקודות

פקודה Description
pac power-fx repl (תצוגה מקדימה) הפעלת קריאה אינטראקטיבית של Power Fx -Eval-Print לולאה
pac power-fx run (תצוגה מקדימה) הפעלת קובץ של הוראות Power Fx

pac power-fx repl

(תצוגה מקדימה) הפעלת קריאה אינטראקטיבית של Power Fx -Eval-Print לולאה

הערה

אם התקנת את Power Platform CLI באמצעות Windows MSI, pac power-fx repl קיימת בעיה ידועה שבה המעטפת עלולה להפסיק להגיב בעת שימוש בפקודה זו.

פרמטרים אופציונליים עבור power-fx repl

--environment -env

מציין את target Dataverse. הערך עשוי להיות GUID או כתובת URL מוחלטת של https. כאשר לא צוין, המערכת תשמש את הארגון הפעיל שנבחר עבור פרופיל האימות הנוכחי.

Remarks

פקודה זו מספקת מעטפת לשימוש בנוסחאות המפורטות בהפניה לנוסחאות - Power Platform CLI.

הפעל את ההפצה מחדש של Power Fx על-ידי הפעלת הפקודה הבאה:

pac power-fx repl

לאחר מכן, תוכל להפעיל פקודות Power Fx.

Examples

הדוגמאות הבאות מציגות את השימוש בפקודה pac power-fx repl .

הוספת שורות
Collect(Contacts, { firstname: "Patti", lastname: "Fernandez" })

ההפצה מחדש של Power Fx מגיבה באופן הבא:

{contactid:GUID("118d7b47-8f80-ee11-8179-0022482a40c7"), fullname:"Patti Fernandez", ...}
עזרה

הפעל את הפקודה הבאה כדי לקבל עזרה אודות כל הפקודות הזמינות ב- Power Fx repl:

Help()

ה- Repl של Power Fx מגיב עם הפלט הבא:

  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
>>

הערה

פקודות אלה ישתנו לאורך זמן כדי לכלול פקודות נוספות. יש לסנכרן אותו עם הפקודות הנוכחיות הזמינות לתיעוד.

Exit

השתמש Exit() כדי לצאת מהפקודה repl .

pac power-fx run

(תצוגה מקדימה) הפעלת קובץ של הוראות Power Fx

Examples

הדוגמאות הבאות מציגות את השימוש בפקודה pac power-fx run .

הערה

בכל אחת מהדוגמאות הבאות, עליך:

  1. צור קובץ בשם test-pfx.txt עם ביטויי Power Fx בתיקיה במחשב שלך, כגון c:\test.

  2. פתח חלון של Windows PowerShell, נווט אל testrun התיקיה והשתמש בפקודה המציצת את הקובץ המכיל את הפקודות: pac power-fx run --file test-pfx.txt.

כדי להשתמש בטבלאות Dataverse, עליך ליצור ולבחור פרופיל אימות. ראה pac יצירת אימותובחירהpac באימות.

אם אתה מקבל בדיקת שגיאות פתרון בעיות.

יצירת רשומות Dataverse

  1. הוסף את הטקסט הבא אל test-pfx.txt ושמור את הקובץ.

    Collect(Contacts, { firstname: "Megan", lastname: "Bowen" })
    Collect(Contacts, { firstname: "Garth", lastname: "Forth" })
    Collect(Contacts, { firstname: "Adele", lastname: "Vance" })
    Collect(Contacts, { firstname: "Patti", lastname: "Fernandez" })
    
  2. הפעל פקודה זו:

    PS C:\test> pac power-fx run --file test-pfx.txt
    

    תוכל לצפות לפלט באופן הבא:

    {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", ...}
    

ביצוע שאילתה על טבלה Dataverse

  1. הוסף טקסט זה אל test-pfx.txt ושמור את הקובץ.

    FirstN(Contacts, 5)
    

    פקודה זו מאחזרת את חמשת אנשי הקשר הראשונים מ- Dataverse.

  2. הפעל פקודה זו:

    PS C:\test> pac power-fx run --file test-pfx.txt
    

    תוכל לצפות לפלט באופן הבא:

    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>
    

שימוש בפונקציות PowerFx

  1. הוסף את הטקסט הבא אל test-pfx.txt ושמור את הקובץ.

    Set(x, 1)
    Result = If( Mid( "asdf",x,1 ) = "a", "X", "Y" )
    

    דוגמה זו משתמשת בפונקציות Mid, If ו - Set Power Fx.

  2. הפעל את הפקודה הבאה:

    PS C:\test> pac power-fx run --file test-pfx.txt
    

    תוכל לצפות לפלט באופן הבא:

    PS C:\test> pac power-fx run --file test-pfx.txt
    x: 1
    true
    Result: "X"
    PS C:\test>
    
  3. הוסף את --echo הפרמטר וצפה לפלט זה:

    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>
    

פרמטרים נדרשים עבור power-fx run

--file -f

נתיב קובץ לביצוע

פרמטרים אופציונליים עבור power-fx run

--echo -e

True אם פקודות קלט אמורות להדהד בחזרה לפלט

לפרמטר זה אין כל ערך. זה מתג.

--environment -env

מציין את target Dataverse. הערך עשוי להיות GUID או כתובת URL מוחלטת של https. כאשר לא צוין, המערכת תשמש את הארגון הפעיל שנבחר עבור פרופיל האימות הנוכחי.

‏‫פתרון בעיות

להלן שלבים לפתרון שגיאות שאתה עשוי להיתקל בהן בעת שימוש בפקודות pac power-fx .

שגיאה כאשר לא קיים פרופיל אימות Dataverse

באפשרותך לקבל שגיאה כגון זו כאשר אין לך פרופיל אימות אוניברסלי המשויך לסביבה 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.

כדי לפתור שגיאות כגון אלה, צור פרופיל אימות אוניברסלי המשויך לסביבה Dataverse.

  1. הפעל את רשימתpac אימות הפקודות.

    ייתכן שתראה תוצאה כמו הבאה הכוללת UNIVERSAL פרופיל אימות ללא כתובת URL המציינת שהיא משויכת לסביבה Dataverse.

    Index Active Kind      Name Friendly Name Url User                Cloud  Type
    [1]   *      UNIVERSAL                        you@yourcompany.com Public OperatingSystem
    

    פעולה זו אינה מספיקה מאחר שלא צוינה סביבה Dataverse.

  2. השתמש pac ביצירת אימות כדי ליצור פרופיל UNIVERSAL אימות המחובר לסביבה Dataverse.

    הערה

    השתמש בפרמטר --environment באמצעות הערך environmentid. חפש את מזהה הסביבה שלך.

    אל תשתמש בפרמטר --url מאחר שהפעולה תיצור DATAVERSE פרופיל ולא פרופיל UNIVERSAL .

    לדוגמה:

    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>
    
  3. הפעל pac שוב את רשימת האימות. אתה אמור לראות תוצאה עם פרופיל UNIVERSAL חיבור עם כתובת URL עבור סביבת Dataverse שלך.

    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>
    
  4. בחר את הסביבה UNIVERSAL כדי להפוך אותה לפרופיל ברירת המחדל באמצעותpac פקודת בחירת האימות.

    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>
    

ראה גם

קבוצות פקודות CLI של Microsoft Power Platform
מבט כולל על Microsoft Power Platform CLI