What should you do?

You create an audience named “Sales” that contains one rule. You plan to add a second rule that contains an “or” condition. You write the following code segment.

01: Using objSite as SPWeb = New SPSite(“http://internet”).OpenWeb()
02:
03: Dim AM as New
AudienceManager(Microsoft.Office.Server.ServerContext.GetContext(objSite.site())
04: Dim Sales as Audience = AM.GetAudiences(“Sales”)
05:
06: Dim R1 as New AudienceRulesComponent(Nothing, “OR”, Nothing)
07: Sales.AudienceRules.Add(R1)
08: Dim R2 as New AudienceRulesComponent(“AccountName”, “Contains”, “Sales”)
09: Sales.AudienceRules.Add(R2)
10: Sales.Commit()
11:
12: End Using

You run the code in your development environment. You notice that the second rule is not created. You need to ensure that both rules are created when you run the code in the production environment.

What should you do?

You create an audience named “Sales” that contains one rule. You plan to add a second rule that contains an “or” condition. You write the following code segment.

01: Using objSite as SPWeb = New SPSite(“http://internet”).OpenWeb()
02:
03: Dim AM as New
AudienceManager(Microsoft.Office.Server.ServerContext.GetContext(objSite.site())
04: Dim Sales as Audience = AM.GetAudiences(“Sales”)
05:
06: Dim R1 as New AudienceRulesComponent(Nothing, “OR”, Nothing)
07: Sales.AudienceRules.Add(R1)
08: Dim R2 as New AudienceRulesComponent(“AccountName”, “Contains”, “Sales”)
09: Sales.AudienceRules.Add(R2)
10: Sales.Commit()
11:
12: End Using

You run the code in your development environment. You notice that the second rule is not created. You need to ensure that both rules are created when you run the code in the production environment.

What should you do?

A.
Add the following code at line 5:
Sales.GroupOperation = AudienceGroupOperation.Audience_OR_Operation

B.
Remove Line 6 and Line 7

C.
Replace Line 10 with the following line of code:
Sales.ReloadMembership()

D.
Add the following line of code at line 11:
Sales.ReloadMembership()



Leave a Reply 0

Your email address will not be published. Required fields are marked *